Skip to content

Commit

Permalink
PlainTransportDump tuple is required
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Aug 30, 2023
1 parent e54c0d0 commit c231582
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 49 deletions.
51 changes: 14 additions & 37 deletions rust/src/fbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71554,8 +71554,7 @@ mod root {
/// The field `comedia` in the table `DumpResponse`
pub comedia: bool,
/// The field `tuple` in the table `DumpResponse`
pub tuple:
::core::option::Option<::planus::alloc::boxed::Box<super::transport::Tuple>>,
pub tuple: ::planus::alloc::boxed::Box<super::transport::Tuple>,
/// The field `rtcp_tuple` in the table `DumpResponse`
pub rtcp_tuple:
::core::option::Option<::planus::alloc::boxed::Box<super::transport::Tuple>>,
Expand All @@ -71578,9 +71577,7 @@ mod root {
field_base: impl ::planus::WriteAs<::planus::Offset<super::transport::Dump>>,
field_rtcp_mux: impl ::planus::WriteAsDefault<bool, bool>,
field_comedia: impl ::planus::WriteAsDefault<bool, bool>,
field_tuple: impl ::planus::WriteAsOptional<
::planus::Offset<super::transport::Tuple>,
>,
field_tuple: impl ::planus::WriteAs<::planus::Offset<super::transport::Tuple>>,
field_rtcp_tuple: impl ::planus::WriteAsOptional<
::planus::Offset<super::transport::Tuple>,
>,
Expand All @@ -71598,9 +71595,7 @@ mod root {
let mut table_writer: ::planus::table_writer::TableWriter<16> =
::core::default::Default::default();
table_writer.write_entry::<::planus::Offset<super::transport::Dump>>(0);
if prepared_tuple.is_some() {
table_writer.write_entry::<::planus::Offset<super::transport::Tuple>>(3);
}
table_writer.write_entry::<::planus::Offset<super::transport::Tuple>>(3);
if prepared_rtcp_tuple.is_some() {
table_writer.write_entry::<::planus::Offset<super::transport::Tuple>>(4);
}
Expand All @@ -71618,9 +71613,7 @@ mod root {
unsafe {
table_writer.finish(builder, |object_writer| {
object_writer.write::<_, _, 4>(&prepared_base);
if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple {
object_writer.write::<_, _, 4>(&prepared_tuple);
}
object_writer.write::<_, _, 4>(&prepared_tuple);
if let ::core::option::Option::Some(prepared_rtcp_tuple) =
prepared_rtcp_tuple
{
Expand Down Expand Up @@ -71757,18 +71750,11 @@ mod root {
#[allow(clippy::type_complexity)]
pub fn tuple<T3>(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)>
where
T3: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T3: ::planus::WriteAs<::planus::Offset<super::transport::Tuple>>,
{
let (v0, v1, v2) = self.0;
DumpResponseBuilder((v0, v1, v2, value))
}

/// Sets the [`tuple` field](DumpResponse#structfield.tuple) to null.
#[inline]
#[allow(clippy::type_complexity)]
pub fn tuple_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, ())> {
self.tuple(())
}
}

impl<T0, T1, T2, T3> DumpResponseBuilder<(T0, T1, T2, T3)> {
Expand Down Expand Up @@ -71836,7 +71822,7 @@ mod root {
T0: ::planus::WriteAs<::planus::Offset<super::transport::Dump>>,
T1: ::planus::WriteAsDefault<bool, bool>,
T2: ::planus::WriteAsDefault<bool, bool>,
T3: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T3: ::planus::WriteAs<::planus::Offset<super::transport::Tuple>>,
T4: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T5: ::planus::WriteAsOptional<::planus::Offset<super::transport::SrtpParameters>>,
> ::planus::WriteAs<::planus::Offset<DumpResponse>>
Expand All @@ -71857,7 +71843,7 @@ mod root {
T0: ::planus::WriteAs<::planus::Offset<super::transport::Dump>>,
T1: ::planus::WriteAsDefault<bool, bool>,
T2: ::planus::WriteAsDefault<bool, bool>,
T3: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T3: ::planus::WriteAs<::planus::Offset<super::transport::Tuple>>,
T4: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T5: ::planus::WriteAsOptional<::planus::Offset<super::transport::SrtpParameters>>,
> ::planus::WriteAsOptional<::planus::Offset<DumpResponse>>
Expand All @@ -71878,7 +71864,7 @@ mod root {
T0: ::planus::WriteAs<::planus::Offset<super::transport::Dump>>,
T1: ::planus::WriteAsDefault<bool, bool>,
T2: ::planus::WriteAsDefault<bool, bool>,
T3: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T3: ::planus::WriteAs<::planus::Offset<super::transport::Tuple>>,
T4: ::planus::WriteAsOptional<::planus::Offset<super::transport::Tuple>>,
T5: ::planus::WriteAsOptional<::planus::Offset<super::transport::SrtpParameters>>,
> ::planus::WriteAsOffset<DumpResponse>
Expand Down Expand Up @@ -71927,11 +71913,8 @@ mod root {

/// Getter for the [`tuple` field](DumpResponse#structfield.tuple).
#[inline]
pub fn tuple(
&self,
) -> ::planus::Result<::core::option::Option<super::transport::TupleRef<'a>>>
{
self.0.access(3, "DumpResponse", "tuple")
pub fn tuple(&self) -> ::planus::Result<super::transport::TupleRef<'a>> {
self.0.access_required(3, "DumpResponse", "tuple")
}

/// Getter for the [`rtcp_tuple` field](DumpResponse#structfield.rtcp_tuple).
Expand Down Expand Up @@ -71959,9 +71942,7 @@ mod root {
f.field("base", &self.base());
f.field("rtcp_mux", &self.rtcp_mux());
f.field("comedia", &self.comedia());
if let ::core::option::Option::Some(field_tuple) = self.tuple().transpose() {
f.field("tuple", &field_tuple);
}
f.field("tuple", &self.tuple());
if let ::core::option::Option::Some(field_rtcp_tuple) =
self.rtcp_tuple().transpose()
{
Expand All @@ -71987,13 +71968,9 @@ mod root {
)?),
rtcp_mux: ::core::convert::TryInto::try_into(value.rtcp_mux()?)?,
comedia: ::core::convert::TryInto::try_into(value.comedia()?)?,
tuple: if let ::core::option::Option::Some(tuple) = value.tuple()? {
::core::option::Option::Some(::planus::alloc::boxed::Box::new(
::core::convert::TryInto::try_into(tuple)?,
))
} else {
::core::option::Option::None
},
tuple: ::planus::alloc::boxed::Box::new(
::core::convert::TryInto::try_into(value.tuple()?)?,
),
rtcp_tuple: if let ::core::option::Option::Some(rtcp_tuple) =
value.rtcp_tuple()?
{
Expand Down
6 changes: 1 addition & 5 deletions rust/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,11 +994,7 @@ impl RequestFbs for RouterCreatePlainTransportRequest {
};

Ok(PlainTransportData {
tuple: Mutex::new(
data.tuple
.map(|tuple| TransportTuple::from_fbs(tuple.as_ref()))
.unwrap(),
),
tuple: Mutex::new(TransportTuple::from_fbs(data.tuple.as_ref())),
rtcp_tuple: Mutex::new(
data.rtcp_tuple
.map(|tuple| TransportTuple::from_fbs(tuple.as_ref())),
Expand Down
7 changes: 3 additions & 4 deletions rust/src/router/plain_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub struct PlainTransportDump {
// PlainTransport specific.
pub rtcp_mux: bool,
pub comedia: bool,
pub tuple: Option<TransportTuple>,
pub tuple: TransportTuple,
pub rtcp_tuple: Option<TransportTuple>,
pub srtp_parameters: Option<SrtpParameters>,
}
Expand Down Expand Up @@ -197,9 +197,7 @@ impl PlainTransportDump {
// PlainTransport specific.
rtcp_mux: dump.rtcp_mux,
comedia: dump.comedia,
tuple: dump
.tuple
.map(|tuple| TransportTuple::from_fbs(tuple.as_ref())),
tuple: TransportTuple::from_fbs(dump.tuple.as_ref()),
rtcp_tuple: dump
.rtcp_tuple
.map(|tuple| TransportTuple::from_fbs(tuple.as_ref())),
Expand All @@ -209,6 +207,7 @@ impl PlainTransportDump {
})
}
}

/// RTC statistics of the plain transport.
#[derive(Debug, Clone, PartialOrd, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
4 changes: 2 additions & 2 deletions rust/tests/integration/plain_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn create_succeeds() {
assert!(!transport_dump.direct);
assert_eq!(transport_dump.producer_ids, vec![]);
assert_eq!(transport_dump.consumer_ids, vec![]);
assert_eq!(transport_dump.tuple.unwrap(), transport1.tuple());
assert_eq!(transport_dump.tuple, transport1.tuple());
assert_eq!(transport_dump.rtcp_tuple, transport1.rtcp_tuple());
assert_eq!(transport_dump.srtp_parameters, transport1.srtp_parameters());
assert_eq!(transport_dump.sctp_state, transport1.sctp_state());
Expand Down Expand Up @@ -260,7 +260,7 @@ fn create_succeeds() {

assert_eq!(transport_dump.id, transport2.id());
assert!(!transport_dump.direct);
assert_eq!(transport_dump.tuple.unwrap(), transport2.tuple());
assert_eq!(transport_dump.tuple, transport2.tuple());
assert_eq!(transport_dump.rtcp_tuple, transport2.rtcp_tuple());
assert_eq!(transport_dump.sctp_state, transport2.sctp_state());
}
Expand Down
2 changes: 1 addition & 1 deletion worker/fbs/plainTransport.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ table DumpResponse {
base:FBS.Transport.Dump (required);
rtcp_mux:bool;
comedia:bool;
tuple:FBS.Transport.Tuple;
tuple:FBS.Transport.Tuple (required);
rtcp_tuple:FBS.Transport.Tuple;
srtp_parameters:FBS.Transport.SrtpParameters;
}
Expand Down

0 comments on commit c231582

Please sign in to comment.