Skip to content

Commit

Permalink
Rust WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jan 2, 2024
1 parent 54d8e7b commit 6e785dc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions rust/src/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub struct ListenInfo {
/// Listening port.
#[serde(skip_serializing_if = "Option::is_none")]
pub port: Option<u16>,
/// Socket flags.
#[serde(skip_serializing_if = "Option::is_none")]
pub flags: Option<Vec<SocketFlag>>,
/// Send buffer size (bytes).
#[serde(skip_serializing_if = "Option::is_none")]
pub send_buffer_size: Option<u32>,
Expand Down Expand Up @@ -190,6 +193,26 @@ impl Protocol {
}
}

/// Transport socket flag.
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum SocketFlag {
/// Disable dual-stack support so only IPv6 is used (only if ip is IPv6).
IpV6Only,
/// Make different transports bind to the same ip and port (only for UDP).
/// Useful for multicast scenarios with plain transport. Use with caution.
UdpReusePort,
}

impl SocketFlag {
pub(crate) fn to_fbs(self) -> transport::SocketFlag {
match self {
SocketFlag::IpV6Only => transport::SocketFlag::IPV6ONLY,
SocketFlag::UdpReusePort => transport::SocketFlag::UDP_REUSEPORT,
}
}
}

/// ICE candidate
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down

0 comments on commit 6e785dc

Please sign in to comment.