rust_webrtc/protocol/src/lib.rs

36 lines
787 B
Rust
Raw Normal View History

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
2025-04-14 04:58:44 +03:00
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum SignalType {
Auth,
Offer,
Answer,
}
2025-04-14 04:58:44 +03:00
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Signal {
pub username: String,
2025-04-14 04:58:44 +03:00
pub signal_type: SignalType,
pub data: String,
time: DateTime<Utc>,
}
2025-04-14 04:58:44 +03:00
impl Signal {
pub fn new(username: &String, signal_type: &SignalType, data: &String) -> Signal {
let username = username.to_owned();
let signal_type = *signal_type;
let data = data.to_owned();
Signal {
username,
signal_type,
data,
time: DateTime::default(),
}
}
pub fn get_time(&self) -> DateTime<Utc> {
self.time
}
}