Skip to content

Commit

Permalink
proto: use structured enum rather than tuple enums
Browse files Browse the repository at this point in the history
Provides more context as to what the values mean.  Especially when
multiple values have the same type.
  • Loading branch information
ystreet committed Oct 21, 2024
1 parent 31348da commit ed37999
Show file tree
Hide file tree
Showing 6 changed files with 322 additions and 170 deletions.
25 changes: 17 additions & 8 deletions librice-proto/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ impl Agent {
}
break;
}
CheckListSetPollRet::Transmit(checklist_id, cid, transmit) => {
CheckListSetPollRet::Transmit {
checklist_id,
component_id: cid,
transmit,
} => {
if let Some(stream) =
self.streams.iter().find(|s| s.checklist_id == checklist_id)
{
Expand All @@ -309,7 +313,12 @@ impl Agent {
);
}
}
CheckListSetPollRet::TcpConnect(checklist_id, cid, from, to) => {
CheckListSetPollRet::TcpConnect {
checklist_id,
component_id: cid,
local_addr: from,
remote_addr: to,
} => {
if let Some(stream) =
self.streams.iter().find(|s| s.checklist_id == checklist_id)
{
Expand All @@ -323,10 +332,10 @@ impl Agent {
warn!("did not find stream for tcp connect {from:?} -> {to:?}");
}
}
CheckListSetPollRet::Event(
CheckListSetPollRet::Event {
checklist_id,
ConnCheckEvent::ComponentState(cid, state),
) => {
event: ConnCheckEvent::ComponentState(cid, state),
} => {
if let Some(stream) =
self.streams.iter().find(|s| s.checklist_id == checklist_id)
{
Expand All @@ -339,10 +348,10 @@ impl Agent {
}
}
}
CheckListSetPollRet::Event(
CheckListSetPollRet::Event {
checklist_id,
ConnCheckEvent::SelectedPair(cid, selected),
) => {
event: ConnCheckEvent::SelectedPair(cid, selected),
} => {
if let Some(stream) =
self.streams.iter().find(|s| s.checklist_id == checklist_id)
{
Expand Down
21 changes: 15 additions & 6 deletions librice-proto/src/capi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,21 @@ impl RiceGatherPoll {
GatherPoll::WaitUntil(instant) => Self::WaitUntilMicros(
instant.saturating_duration_since(base_instant).as_micros() as u64,
),
GatherPoll::NeedAgent(component_id, transport, from, to) => Self::NeedAgent(
RiceGatherPollNeedAgent::from_rust(component_id, transport, from, to),
),
GatherPoll::SendData(component_id, transmit) => {
Self::SendData(transmit_from_rust_gather(stream_id, component_id, transmit))
}
GatherPoll::NeedAgent {
component_id,
transport,
local_addr: from,
remote_addr: to,
} => Self::NeedAgent(RiceGatherPollNeedAgent::from_rust(
component_id,
transport,
from,
to,
)),
GatherPoll::SendData {
component_id,
transmit,
} => Self::SendData(transmit_from_rust_gather(stream_id, component_id, transmit)),
GatherPoll::NewCandidate(cand) => {
Self::NewCandidate(Box::into_raw(Box::new(cand.into())))
}
Expand Down
Loading

0 comments on commit ed37999

Please sign in to comment.