Skip to content

Commit

Permalink
remove clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiy-0x62 committed Jan 14, 2025
1 parent 641b436 commit 4e48d00
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 78 deletions.
42 changes: 21 additions & 21 deletions src/discovery/structure/cdr/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ macro_rules! impl_deserialize_value {
};
}

impl<'de, 'a, R, S, E> de::Deserializer<'de> for &'a mut Deserializer<R, S, E>
impl<'de, R, S, E> de::Deserializer<'de> for &mut Deserializer<R, S, E>
where
R: Read,
S: SizeLimit,
Expand Down Expand Up @@ -320,25 +320,6 @@ where
where
V: de::Visitor<'de>,
{
impl<'de, 'a, R, S, E> de::EnumAccess<'de> for &'a mut Deserializer<R, S, E>
where
R: Read + 'a,
S: SizeLimit,
E: ByteOrder,
{
type Error = Error;
type Variant = Self;

fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant)>
where
V: de::DeserializeSeed<'de>,
{
let idx: u32 = de::Deserialize::deserialize(&mut *self)?;
let val: Result<_> = seed.deserialize(idx.into_deserializer());
Ok((val?, self))
}
}

visitor.visit_enum(self)
}

Expand All @@ -361,7 +342,7 @@ where
}
}

impl<'de, 'a, R, S, E> de::VariantAccess<'de> for &'a mut Deserializer<R, S, E>
impl<'de, R, S, E> de::VariantAccess<'de> for &mut Deserializer<R, S, E>
where
R: Read,
S: SizeLimit,
Expand Down Expand Up @@ -395,6 +376,25 @@ where
}
}

impl<'de, 'a, R, S, E> de::EnumAccess<'de> for &'a mut Deserializer<R, S, E>
where
R: Read + 'a,
S: SizeLimit,
E: ByteOrder,
{
type Error = Error;
type Variant = Self;

fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant)>
where
V: de::DeserializeSeed<'de>,
{
let idx: u32 = de::Deserialize::deserialize(&mut *self)?;
let val: Result<_> = seed.deserialize(idx.into_deserializer());
Ok((val?, self))
}
}

impl<R, S> From<Deserializer<R, S, BigEndian>> for Deserializer<R, S, LittleEndian> {
fn from(t: Deserializer<R, S, BigEndian>) -> Self {
Self {
Expand Down
14 changes: 7 additions & 7 deletions src/discovery/structure/cdr/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub struct SizeCompound<'a, S: 'a> {
ser: &'a mut SizeChecker<S>,
}

impl<'a, S> ser::SerializeSeq for SizeCompound<'a, S>
impl<S> ser::SerializeSeq for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand All @@ -277,7 +277,7 @@ where
}
}

impl<'a, S> ser::SerializeTuple for SizeCompound<'a, S>
impl<S> ser::SerializeTuple for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand All @@ -298,7 +298,7 @@ where
}
}

impl<'a, S> ser::SerializeTupleStruct for SizeCompound<'a, S>
impl<S> ser::SerializeTupleStruct for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand All @@ -319,7 +319,7 @@ where
}
}

impl<'a, S> ser::SerializeTupleVariant for SizeCompound<'a, S>
impl<S> ser::SerializeTupleVariant for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand All @@ -340,7 +340,7 @@ where
}
}

impl<'a, S> ser::SerializeMap for SizeCompound<'a, S>
impl<S> ser::SerializeMap for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand Down Expand Up @@ -369,7 +369,7 @@ where
}
}

impl<'a, S> ser::SerializeStruct for SizeCompound<'a, S>
impl<S> ser::SerializeStruct for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand All @@ -390,7 +390,7 @@ where
}
}

impl<'a, S> ser::SerializeStructVariant for SizeCompound<'a, S>
impl<S> ser::SerializeStructVariant for SizeCompound<'_, S>
where
S: SizeLimit,
{
Expand Down
63 changes: 13 additions & 50 deletions src/discovery/structure/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,45 +145,17 @@ impl SDPBuiltinData {
}

pub fn gen_spdp_discoverd_participant_data(&mut self) -> Option<SPDPdiscoveredParticipantData> {
let domain_id = match self.domain_id {
Some(did) => did,
None => return None,
}; // TODO: set domain_id of this participant if domain_id is none
let domain_id = self.domain_id?; // TODO: set domain_id of this participant if domain_id is none
let _domain_tag = self.domain_tag.take().unwrap_or(String::from(""));
let protocol_version = match self.protocol_version.take() {
Some(pv) => pv,
None => return None,
};
let guid = match self.guid {
Some(g) => g,
None => return None,
};
let vendor_id = match self.vendor_id {
Some(vid) => vid,
None => return None,
};
let protocol_version = self.protocol_version.take()?;
let guid = self.guid?;
let vendor_id = self.vendor_id?;
let expects_inline_qos = self.expects_inline_qos.unwrap_or(false);
let available_builtin_endpoint = match self.available_builtin_endpoint {
Some(abe) => abe,
None => return None,
};
let metarraffic_unicast_locator_list = match self.metarraffic_unicast_locator_list.take() {
Some(mull) => mull,
None => return None,
};
let metarraffic_multicast_locator_list =
match self.metarraffic_multicast_locator_list.take() {
Some(mmll) => mmll,
None => return None,
};
let default_unicast_locator_list = match self.default_unicast_locator_list.take() {
Some(dull) => dull,
None => return None,
};
let default_multicast_locator_list = match self.default_multicast_locator_list.take() {
Some(dmll) => dmll,
None => return None,
};
let available_builtin_endpoint = self.available_builtin_endpoint?;
let metarraffic_unicast_locator_list = self.metarraffic_unicast_locator_list.take()?;
let metarraffic_multicast_locator_list = self.metarraffic_multicast_locator_list.take()?;
let default_unicast_locator_list = self.default_unicast_locator_list.take()?;
let default_multicast_locator_list = self.default_multicast_locator_list.take()?;
let manual_liveliness_count = self.manual_liveliness_count;
let lease_duration = self.lease_duration.unwrap_or(Duration {
seconds: 100,
Expand Down Expand Up @@ -223,19 +195,10 @@ impl SDPBuiltinData {
&mut self,
history_cache: Arc<RwLock<HistoryCache>>,
) -> Option<ReaderProxy> {
let remote_guid = match self.remote_guid {
Some(rg) => rg,
None => return None,
};
let remote_guid = self.remote_guid?;
let expects_inline_qos = self.expects_inline_qos.unwrap_or(false);
let unicast_locator_list = match self.unicast_locator_list.take() {
Some(ull) => ull,
None => return None,
};
let multicast_locator_list = match self.multicast_locator_list.take() {
Some(mll) => mll,
None => return None,
};
let unicast_locator_list = self.unicast_locator_list.take()?;
let multicast_locator_list = self.multicast_locator_list.take()?;
let dr_qos_builder = DataReaderQosBuilder::new();
let qos = dr_qos_builder
.durability(self.durability.unwrap_or_default())
Expand Down Expand Up @@ -386,7 +349,7 @@ impl<'de> Deserialize<'de> for SDPBuiltinData {
{
struct FieldVisitor;

impl<'de> Visitor<'de> for FieldVisitor {
impl Visitor<'_> for FieldVisitor {
type Value = Field;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a RTPS serialized_payload")
Expand Down

0 comments on commit 4e48d00

Please sign in to comment.