docs(rust): add doc comments to delta enums and fix dead_code warnings (#24)
* docs(rust): add doc comments to delta enums and fix dead_code warnings Add missing documentation to ProtocolDelta, CoreDelta, and BridgeDelta enum variants and their struct fields across the protocol, core, and bridge crates. Document the ChannelId::ROOT constant and the take_delta_rx adapter method. Fix dead_code warnings: - keyring_disabled: add #[cfg] gate matching its callers - snapshot_signature: add #[cfg(test)] for future test use * fix(rust): correct `order` field docs to predecessor channel ID, narrow audio engine cfg gates - Correct `order` field documentation in ProtocolDelta, SessionEvent, and BridgeEvent from 'sort order' to 'predecessor channel ID (TeamSpeak linked-list ordering hint)' per Copilot review feedback. - Narrow AudioEngine voice_out_tx, voice_activity_selector, and mic_gain cfg gates from ios+macos+android to android-only, since these fields are only read from self in android_restart_voice_unit. On iOS/macOS the values are passed directly to the voice backend at construction time.
This commit is contained in:
@@ -253,49 +253,87 @@ pub enum SessionEvent {
|
|||||||
},
|
},
|
||||||
/// Audio route changed (speaker/earpiece/BT/wired headset).
|
/// Audio route changed (speaker/earpiece/BT/wired headset).
|
||||||
AudioRouteChanged {
|
AudioRouteChanged {
|
||||||
|
/// New audio output route.
|
||||||
route: AudioRoute,
|
route: AudioRoute,
|
||||||
},
|
},
|
||||||
|
/// A client moved to a different channel.
|
||||||
ClientMoved {
|
ClientMoved {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Destination channel.
|
||||||
new_channel_id: u64,
|
new_channel_id: u64,
|
||||||
},
|
},
|
||||||
|
/// A new client connected.
|
||||||
ClientJoined {
|
ClientJoined {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Channel the client joined.
|
||||||
channel_id: u64,
|
channel_id: u64,
|
||||||
|
/// Display nickname.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Microphone muted state.
|
||||||
input_muted: bool,
|
input_muted: bool,
|
||||||
|
/// Speaker muted state.
|
||||||
output_muted: bool,
|
output_muted: bool,
|
||||||
|
/// Whether this is a server query (bot) client.
|
||||||
is_server_query: bool,
|
is_server_query: bool,
|
||||||
|
/// Client's talk power value.
|
||||||
talk_power: i32,
|
talk_power: i32,
|
||||||
|
/// Whether the server granted temporary talk power.
|
||||||
talk_power_granted: bool,
|
talk_power_granted: bool,
|
||||||
},
|
},
|
||||||
|
/// A client disconnected.
|
||||||
ClientLeft {
|
ClientLeft {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Display nickname at time of disconnect.
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
/// Client properties changed.
|
||||||
ClientUpdated {
|
ClientUpdated {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Microphone muted state.
|
||||||
input_muted: bool,
|
input_muted: bool,
|
||||||
|
/// Speaker muted state.
|
||||||
output_muted: bool,
|
output_muted: bool,
|
||||||
|
/// Whether this is a server query (bot) client.
|
||||||
is_server_query: bool,
|
is_server_query: bool,
|
||||||
|
/// Client's talk power value.
|
||||||
talk_power: i32,
|
talk_power: i32,
|
||||||
|
/// Whether the server granted temporary talk power.
|
||||||
talk_power_granted: bool,
|
talk_power_granted: bool,
|
||||||
},
|
},
|
||||||
|
/// A new channel appeared.
|
||||||
ChannelAdded {
|
ChannelAdded {
|
||||||
|
/// Unique channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
|
/// Parent channel ID.
|
||||||
parent: u64,
|
parent: u64,
|
||||||
|
/// Channel name.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Predecessor channel ID within the same parent (TeamSpeak
|
||||||
|
/// linked-list ordering hint). Zero means first child.
|
||||||
order: i64,
|
order: i64,
|
||||||
|
/// Whether the channel requires a password.
|
||||||
has_password: bool,
|
has_password: bool,
|
||||||
|
/// Talk power required to speak, or `None` when unrestricted.
|
||||||
needed_talk_power: Option<i32>,
|
needed_talk_power: Option<i32>,
|
||||||
},
|
},
|
||||||
|
/// A channel was deleted.
|
||||||
ChannelRemoved {
|
ChannelRemoved {
|
||||||
|
/// Channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
},
|
},
|
||||||
|
/// Channel properties changed.
|
||||||
ChannelUpdated {
|
ChannelUpdated {
|
||||||
|
/// Unique channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
|
/// Channel name.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Whether the channel requires a password.
|
||||||
has_password: bool,
|
has_password: bool,
|
||||||
|
/// Talk power required to speak, or `None` when unrestricted.
|
||||||
needed_talk_power: Option<i32>,
|
needed_talk_power: Option<i32>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -2399,6 +2437,7 @@ async fn supervisor_loop(ctx: SupervisorContext) {
|
|||||||
/// the UI would render. Two snapshots with identical channel
|
/// the UI would render. Two snapshots with identical channel
|
||||||
/// memberships, names, and orderings produce the same signature;
|
/// memberships, names, and orderings produce the same signature;
|
||||||
/// any in-channel move, rename, or reorder produces a different one.
|
/// any in-channel move, rename, or reorder produces a different one.
|
||||||
|
#[cfg(test)]
|
||||||
fn snapshot_signature(snap: &ServerSnapshot) -> u64 {
|
fn snapshot_signature(snap: &ServerSnapshot) -> u64 {
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|||||||
@@ -306,11 +306,11 @@ pub struct AudioEngine {
|
|||||||
audio_processing_config: Arc<Mutex<crate::AudioProcessingConfig>>,
|
audio_processing_config: Arc<Mutex<crate::AudioProcessingConfig>>,
|
||||||
audio_processing_stats: Arc<crate::SharedAudioProcessingStats>,
|
audio_processing_stats: Arc<crate::SharedAudioProcessingStats>,
|
||||||
audio_handler: Arc<Mutex<AudioHandler<SessionAudioId>>>,
|
audio_handler: Arc<Mutex<AudioHandler<SessionAudioId>>>,
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
|
#[cfg(target_os = "android")]
|
||||||
voice_out_tx: mpsc::Sender<OutPacket>,
|
voice_out_tx: mpsc::Sender<OutPacket>,
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
|
#[cfg(target_os = "android")]
|
||||||
voice_activity_selector: Option<Arc<crate::TransmitModeSelector>>,
|
voice_activity_selector: Option<Arc<crate::TransmitModeSelector>>,
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
|
#[cfg(target_os = "android")]
|
||||||
mic_gain: f32,
|
mic_gain: f32,
|
||||||
// Streams must be dropped to stop audio. Both are `!Send` because
|
// Streams must be dropped to stop audio. Both are `!Send` because
|
||||||
// cpal's Stream isn't Send on some backends; we keep them in an
|
// cpal's Stream isn't Send on some backends; we keep them in an
|
||||||
@@ -1308,9 +1308,6 @@ impl AudioEngine {
|
|||||||
audio_processing_config,
|
audio_processing_config,
|
||||||
audio_processing_stats,
|
audio_processing_stats,
|
||||||
audio_handler,
|
audio_handler,
|
||||||
voice_out_tx,
|
|
||||||
voice_activity_selector: cfg.voice_activity_selector.clone(),
|
|
||||||
mic_gain: cfg.mic_gain,
|
|
||||||
_ios_voice_backend: Mutex::new(Some(ios_voice_backend)),
|
_ios_voice_backend: Mutex::new(Some(ios_voice_backend)),
|
||||||
shutdown_tx: Some(shutdown_tx),
|
shutdown_tx: Some(shutdown_tx),
|
||||||
capture_active,
|
capture_active,
|
||||||
|
|||||||
@@ -1701,49 +1701,87 @@ pub enum BridgeEvent {
|
|||||||
},
|
},
|
||||||
/// Audio route changed (speaker/earpiece/BT/wired).
|
/// Audio route changed (speaker/earpiece/BT/wired).
|
||||||
AudioRouteChanged {
|
AudioRouteChanged {
|
||||||
|
/// New audio output route.
|
||||||
route: BridgeAudioRoute,
|
route: BridgeAudioRoute,
|
||||||
},
|
},
|
||||||
|
/// A client moved to a different channel.
|
||||||
ClientMoved {
|
ClientMoved {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Destination channel.
|
||||||
new_channel_id: u64,
|
new_channel_id: u64,
|
||||||
},
|
},
|
||||||
|
/// A new client connected.
|
||||||
ClientJoined {
|
ClientJoined {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Channel the client joined.
|
||||||
channel_id: u64,
|
channel_id: u64,
|
||||||
|
/// Display nickname.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Microphone muted state.
|
||||||
input_muted: bool,
|
input_muted: bool,
|
||||||
|
/// Speaker muted state.
|
||||||
output_muted: bool,
|
output_muted: bool,
|
||||||
|
/// True for server query (bot) clients.
|
||||||
is_server_query: bool,
|
is_server_query: bool,
|
||||||
|
/// Client's talk power value.
|
||||||
talk_power: i32,
|
talk_power: i32,
|
||||||
|
/// Whether the server granted temporary talk power.
|
||||||
talk_power_granted: bool,
|
talk_power_granted: bool,
|
||||||
},
|
},
|
||||||
|
/// A client disconnected.
|
||||||
ClientLeft {
|
ClientLeft {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Display nickname at time of disconnect.
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
/// Client properties changed.
|
||||||
ClientUpdated {
|
ClientUpdated {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Microphone muted state.
|
||||||
input_muted: bool,
|
input_muted: bool,
|
||||||
|
/// Speaker muted state.
|
||||||
output_muted: bool,
|
output_muted: bool,
|
||||||
|
/// True for server query (bot) clients.
|
||||||
is_server_query: bool,
|
is_server_query: bool,
|
||||||
|
/// Client's talk power value.
|
||||||
talk_power: i32,
|
talk_power: i32,
|
||||||
|
/// Whether the server granted temporary talk power.
|
||||||
talk_power_granted: bool,
|
talk_power_granted: bool,
|
||||||
},
|
},
|
||||||
|
/// A new channel appeared.
|
||||||
ChannelAdded {
|
ChannelAdded {
|
||||||
|
/// Unique channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
|
/// Parent channel ID.
|
||||||
parent: u64,
|
parent: u64,
|
||||||
|
/// Channel name.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Predecessor channel ID within the same parent (TeamSpeak
|
||||||
|
/// linked-list ordering hint). Zero means first child.
|
||||||
order: i64,
|
order: i64,
|
||||||
|
/// Whether the channel requires a password.
|
||||||
has_password: bool,
|
has_password: bool,
|
||||||
|
/// Talk power required to speak; `None` means no restriction.
|
||||||
needed_talk_power: Option<i32>,
|
needed_talk_power: Option<i32>,
|
||||||
},
|
},
|
||||||
|
/// A channel was deleted.
|
||||||
ChannelRemoved {
|
ChannelRemoved {
|
||||||
|
/// Channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
},
|
},
|
||||||
|
/// Channel properties changed.
|
||||||
ChannelUpdated {
|
ChannelUpdated {
|
||||||
|
/// Unique channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
|
/// Channel name.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Whether the channel requires a password.
|
||||||
has_password: bool,
|
has_password: bool,
|
||||||
|
/// Talk power required to speak; `None` means no restriction.
|
||||||
needed_talk_power: Option<i32>,
|
needed_talk_power: Option<i32>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -471,6 +471,9 @@ impl ProtocolClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Takes ownership of the delta receiver channel. Returns `None` if already
|
||||||
|
/// taken. Must be called exactly once during initialization to subscribe to
|
||||||
|
/// incremental state changes.
|
||||||
pub fn take_delta_rx(&self) -> Option<mpsc::Receiver<ProtocolDelta>> {
|
pub fn take_delta_rx(&self) -> Option<mpsc::Receiver<ProtocolDelta>> {
|
||||||
self.delta_rx.lock().ok().and_then(|mut g| g.take())
|
self.delta_rx.lock().ok().and_then(|mut g| g.take())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,52 +168,93 @@ pub struct ServerSnapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelId {
|
impl ChannelId {
|
||||||
|
/// Root/top-level channel identifier.
|
||||||
pub const ROOT: ChannelId = ChannelId(0);
|
pub const ROOT: ChannelId = ChannelId(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Incremental state change emitted by the protocol adapter when the server tree changes.
|
||||||
|
///
|
||||||
|
/// Covers client joins, leaves, moves, and channel additions, removals, and updates.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum ProtocolDelta {
|
pub enum ProtocolDelta {
|
||||||
|
/// A client moved to a different channel.
|
||||||
ClientMoved {
|
ClientMoved {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Destination channel identifier.
|
||||||
new_channel_id: u64,
|
new_channel_id: u64,
|
||||||
},
|
},
|
||||||
|
/// A new client appeared on the server.
|
||||||
ClientJoined {
|
ClientJoined {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Channel the client joined.
|
||||||
channel_id: u64,
|
channel_id: u64,
|
||||||
|
/// Display nickname.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Microphone muted state.
|
||||||
input_muted: bool,
|
input_muted: bool,
|
||||||
|
/// Speaker muted state.
|
||||||
output_muted: bool,
|
output_muted: bool,
|
||||||
|
/// Whether the client is a server query client.
|
||||||
is_server_query: bool,
|
is_server_query: bool,
|
||||||
|
/// Client's talk power value.
|
||||||
talk_power: i32,
|
talk_power: i32,
|
||||||
|
/// Whether the server granted temporary talk power.
|
||||||
talk_power_granted: bool,
|
talk_power_granted: bool,
|
||||||
},
|
},
|
||||||
|
/// A client disconnected.
|
||||||
ClientLeft {
|
ClientLeft {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Display nickname.
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
/// A client's properties changed.
|
||||||
ClientUpdated {
|
ClientUpdated {
|
||||||
|
/// Unique client identifier.
|
||||||
client_id: u64,
|
client_id: u64,
|
||||||
|
/// Microphone muted state.
|
||||||
input_muted: bool,
|
input_muted: bool,
|
||||||
|
/// Speaker muted state.
|
||||||
output_muted: bool,
|
output_muted: bool,
|
||||||
|
/// Whether the client is a server query client.
|
||||||
is_server_query: bool,
|
is_server_query: bool,
|
||||||
|
/// Client's talk power value.
|
||||||
talk_power: i32,
|
talk_power: i32,
|
||||||
|
/// Whether the server granted temporary talk power.
|
||||||
talk_power_granted: bool,
|
talk_power_granted: bool,
|
||||||
},
|
},
|
||||||
|
/// A new channel appeared.
|
||||||
ChannelAdded {
|
ChannelAdded {
|
||||||
|
/// Channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
|
/// Parent channel identifier.
|
||||||
parent: u64,
|
parent: u64,
|
||||||
|
/// Channel name.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Predecessor channel ID within the same parent (TeamSpeak
|
||||||
|
/// linked-list ordering hint). Zero means first child.
|
||||||
order: i64,
|
order: i64,
|
||||||
|
/// Whether the channel has a password.
|
||||||
has_password: bool,
|
has_password: bool,
|
||||||
|
/// Needed talk power, or `None` when unrestricted.
|
||||||
needed_talk_power: Option<i32>,
|
needed_talk_power: Option<i32>,
|
||||||
},
|
},
|
||||||
|
/// A channel was deleted.
|
||||||
ChannelRemoved {
|
ChannelRemoved {
|
||||||
|
/// Channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
},
|
},
|
||||||
|
/// Channel properties changed.
|
||||||
ChannelUpdated {
|
ChannelUpdated {
|
||||||
|
/// Channel identifier.
|
||||||
id: u64,
|
id: u64,
|
||||||
|
/// Channel name.
|
||||||
name: String,
|
name: String,
|
||||||
|
/// Whether the channel has a password.
|
||||||
has_password: bool,
|
has_password: bool,
|
||||||
|
/// Needed talk power, or `None` when unrestricted.
|
||||||
needed_talk_power: Option<i32>,
|
needed_talk_power: Option<i32>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -628,6 +628,12 @@ fn read_file_dek(path: &Path) -> Result<[u8; 32], StorageError> {
|
|||||||
/// headless / sandboxed environments force the file-fallback path
|
/// headless / sandboxed environments force the file-fallback path
|
||||||
/// without poking a real OS keyring (which would either prompt the
|
/// without poking a real OS keyring (which would either prompt the
|
||||||
/// user or block on a missing D-Bus session).
|
/// user or block on a missing D-Bus session).
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "windows",
|
||||||
|
target_os = "ios"
|
||||||
|
))]
|
||||||
fn keyring_disabled() -> bool {
|
fn keyring_disabled() -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
std::env::var("CHANORA_DISABLE_KEYRING").as_deref(),
|
std::env::var("CHANORA_DISABLE_KEYRING").as_deref(),
|
||||||
|
|||||||
Reference in New Issue
Block a user