Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Send and Sync to dyn Errors #1329

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 73 additions & 73 deletions rust/src/messages.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions rust/src/ortc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl RtpMapping {

pub(crate) fn from_fbs_ref(
mapping: rtp_parameters::RtpMappingRef<'_>,
) -> Result<Self, Box<dyn Error>> {
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
codecs: mapping
.codecs()?
Expand All @@ -91,7 +91,7 @@ impl RtpMapping {
mapped_payload_type: mapping?.mapped_payload_type()?,
})
})
.collect::<Result<Vec<_>, Box<dyn Error>>>()?,
.collect::<Result<Vec<_>, Box<dyn Error + Send + Sync>>>()?,
encodings: mapping
.encodings()?
.iter()
Expand All @@ -107,7 +107,7 @@ impl RtpMapping {
mapped_ssrc: mapping?.mapped_ssrc()?,
})
})
.collect::<Result<Vec<_>, Box<dyn Error>>>()?,
.collect::<Result<Vec<_>, Box<dyn Error + Send + Sync>>>()?,
})
}
}
Expand Down
20 changes: 13 additions & 7 deletions rust/src/router/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ pub struct RtpStreamParams {
}

impl RtpStreamParams {
pub(crate) fn from_fbs_ref(params: rtp_stream::ParamsRef<'_>) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs_ref(
params: rtp_stream::ParamsRef<'_>,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
clock_rate: params.clock_rate()?,
cname: params.cname()?.to_string(),
Expand Down Expand Up @@ -197,7 +199,9 @@ pub struct RtxStreamParams {
}

impl RtxStreamParams {
pub(crate) fn from_fbs_ref(params: rtx_stream::ParamsRef<'_>) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs_ref(
params: rtx_stream::ParamsRef<'_>,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
clock_rate: params.clock_rate()?,
cname: params.cname()?.to_string(),
Expand All @@ -218,7 +222,9 @@ pub struct RtpStream {
}

impl RtpStream {
pub(crate) fn from_fbs_ref(dump: rtp_stream::DumpRef<'_>) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs_ref(
dump: rtp_stream::DumpRef<'_>,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
params: RtpStreamParams::from_fbs_ref(dump.params()?)?,
score: dump.score()?,
Expand Down Expand Up @@ -267,7 +273,7 @@ pub struct ConsumerDump {
impl ConsumerDump {
pub(crate) fn from_fbs_ref(
dump: consumer::DumpResponseRef<'_>,
) -> Result<Self, Box<dyn Error>> {
) -> Result<Self, Box<dyn Error + Send + Sync>> {
let dump = dump.data();

Ok(Self {
Expand All @@ -286,7 +292,7 @@ impl ConsumerDump {
.trace_event_types()?
.iter()
.map(|trace_event_type| Ok(ConsumerTraceEventType::from_fbs(trace_event_type?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
r#type: ConsumerType::from_fbs(dump?.base()?.type_()?),
consumable_rtp_encodings: dump?
.base()?
Expand All @@ -295,12 +301,12 @@ impl ConsumerDump {
.map(|encoding_parameters| {
RtpEncodingParameters::from_fbs_ref(encoding_parameters?)
})
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
rtp_streams: dump?
.rtp_streams()?
.iter()
.map(|stream| RtpStream::from_fbs_ref(stream?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
preferred_spatial_layer: dump?.preferred_spatial_layer()?,
target_spatial_layer: dump?.target_spatial_layer()?,
current_spatial_layer: dump?.current_spatial_layer()?,
Expand Down
4 changes: 3 additions & 1 deletion rust/src/router/data_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ pub struct DataConsumerDump {
}

impl DataConsumerDump {
pub(crate) fn from_fbs(dump: data_consumer::DumpResponse) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
dump: data_consumer::DumpResponse,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
id: dump.id.parse()?,
data_producer_id: dump.data_producer_id.parse()?,
Expand Down
4 changes: 3 additions & 1 deletion rust/src/router/data_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ pub struct DataProducerDump {
}

impl DataProducerDump {
pub(crate) fn from_fbs(dump: data_producer::DumpResponse) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
dump: data_producer::DumpResponse,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
id: dump.id.parse()?,
r#type: if dump.type_ == data_producer::Type::Sctp {
Expand Down
18 changes: 10 additions & 8 deletions rust/src/router/direct_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ pub struct DirectTransportDump {
}

impl DirectTransportDump {
pub(crate) fn from_fbs(dump: direct_transport::DumpResponse) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
dump: direct_transport::DumpResponse,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
id: dump.base.id.parse()?,
direct: true,
Expand All @@ -84,37 +86,37 @@ impl DirectTransportDump {
.producer_ids
.iter()
.map(|producer_id| Ok(producer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
consumer_ids: dump
.base
.consumer_ids
.iter()
.map(|consumer_id| Ok(consumer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
map_ssrc_consumer_id: dump
.base
.map_ssrc_consumer_id
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
map_rtx_ssrc_consumer_id: dump
.base
.map_rtx_ssrc_consumer_id
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
data_producer_ids: dump
.base
.data_producer_ids
.iter()
.map(|data_producer_id| Ok(data_producer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
data_consumer_ids: dump
.base
.data_consumer_ids
.iter()
.map(|data_consumer_id| Ok(data_consumer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs(
dump.base.recv_rtp_header_extensions.as_ref(),
),
Expand Down Expand Up @@ -182,7 +184,7 @@ pub struct DirectTransportStat {
impl DirectTransportStat {
pub(crate) fn from_fbs(
stats: direct_transport::GetStatsResponse,
) -> Result<Self, Box<dyn Error>> {
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
transport_id: stats.base.transport_id.parse()?,
timestamp: stats.base.timestamp,
Expand Down
18 changes: 10 additions & 8 deletions rust/src/router/pipe_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ pub struct PipeTransportDump {
}

impl PipeTransportDump {
pub(crate) fn from_fbs(dump: pipe_transport::DumpResponse) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
dump: pipe_transport::DumpResponse,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
// Common to all Transports.
id: dump.base.id.parse()?,
Expand All @@ -116,37 +118,37 @@ impl PipeTransportDump {
.producer_ids
.iter()
.map(|producer_id| Ok(producer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
consumer_ids: dump
.base
.consumer_ids
.iter()
.map(|consumer_id| Ok(consumer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
map_ssrc_consumer_id: dump
.base
.map_ssrc_consumer_id
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
map_rtx_ssrc_consumer_id: dump
.base
.map_rtx_ssrc_consumer_id
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
data_producer_ids: dump
.base
.data_producer_ids
.iter()
.map(|data_producer_id| Ok(data_producer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
data_consumer_ids: dump
.base
.data_consumer_ids
.iter()
.map(|data_consumer_id| Ok(data_consumer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs(
dump.base.recv_rtp_header_extensions.as_ref(),
),
Expand Down Expand Up @@ -223,7 +225,7 @@ pub struct PipeTransportStat {
impl PipeTransportStat {
pub(crate) fn from_fbs(
stats: pipe_transport::GetStatsResponse,
) -> Result<Self, Box<dyn Error>> {
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
transport_id: stats.base.transport_id.parse()?,
timestamp: stats.base.timestamp,
Expand Down
18 changes: 10 additions & 8 deletions rust/src/router/plain_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ pub struct PlainTransportDump {
}

impl PlainTransportDump {
pub(crate) fn from_fbs(dump: plain_transport::DumpResponse) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
dump: plain_transport::DumpResponse,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
// Common to all Transports.
id: dump.base.id.parse()?,
Expand All @@ -137,37 +139,37 @@ impl PlainTransportDump {
.producer_ids
.iter()
.map(|producer_id| Ok(producer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
consumer_ids: dump
.base
.consumer_ids
.iter()
.map(|consumer_id| Ok(consumer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
map_ssrc_consumer_id: dump
.base
.map_ssrc_consumer_id
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
map_rtx_ssrc_consumer_id: dump
.base
.map_rtx_ssrc_consumer_id
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
data_producer_ids: dump
.base
.data_producer_ids
.iter()
.map(|data_producer_id| Ok(data_producer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
data_consumer_ids: dump
.base
.data_consumer_ids
.iter()
.map(|data_consumer_id| Ok(data_consumer_id.parse()?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs(
dump.base.recv_rtp_header_extensions.as_ref(),
),
Expand Down Expand Up @@ -251,7 +253,7 @@ pub struct PlainTransportStat {
impl PlainTransportStat {
pub(crate) fn from_fbs(
stats: plain_transport::GetStatsResponse,
) -> Result<Self, Box<dyn Error>> {
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
transport_id: stats.base.transport_id.parse()?,
timestamp: stats.base.timestamp,
Expand Down
8 changes: 5 additions & 3 deletions rust/src/router/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ pub struct RtpStreamRecv {
}

impl RtpStreamRecv {
pub(crate) fn from_fbs_ref(dump: rtp_stream::DumpRef<'_>) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs_ref(
dump: rtp_stream::DumpRef<'_>,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
params: RtpStreamParams::from_fbs_ref(dump.params()?)?,
score: dump.score()?,
Expand Down Expand Up @@ -141,7 +143,7 @@ pub struct ProducerDump {
impl ProducerDump {
pub(crate) fn from_fbs_ref(
dump: producer::DumpResponseRef<'_>,
) -> Result<Self, Box<dyn Error>> {
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
id: dump.id()?.parse()?,
kind: MediaKind::from_fbs(dump.kind()?),
Expand All @@ -152,7 +154,7 @@ impl ProducerDump {
.rtp_streams()?
.iter()
.map(|rtp_stream| RtpStreamRecv::from_fbs_ref(rtp_stream?))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
trace_event_types: dump
.trace_event_types()?
.iter()
Expand Down
16 changes: 10 additions & 6 deletions rust/src/router/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,25 @@ pub struct RtpListener {
}

impl RtpListener {
pub(crate) fn from_fbs(rtp_listener: &transport::RtpListener) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
rtp_listener: &transport::RtpListener,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
mid_table: rtp_listener
.mid_table
.iter()
.map(|key_value| Ok((key_value.key.to_string(), key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
rid_table: rtp_listener
.rid_table
.iter()
.map(|key_value| Ok((key_value.key.to_string(), key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
ssrc_table: rtp_listener
.ssrc_table
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
})
}
}
Expand Down Expand Up @@ -175,13 +177,15 @@ pub struct SctpListener {
}

impl SctpListener {
pub(crate) fn from_fbs(listener: &transport::SctpListener) -> Result<Self, Box<dyn Error>> {
pub(crate) fn from_fbs(
listener: &transport::SctpListener,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
Ok(Self {
stream_id_table: listener
.stream_id_table
.iter()
.map(|key_value| Ok((key_value.key, key_value.value.parse()?)))
.collect::<Result<_, Box<dyn Error>>>()?,
.collect::<Result<_, Box<dyn Error + Send + Sync>>>()?,
})
}
}
Expand Down
Loading
Loading