1
0
This commit is contained in:
EAimTY 2023-01-25 18:46:40 +09:00
parent 822da1ceaf
commit 000f38da15
3 changed files with 11 additions and 11 deletions

View File

@ -2,5 +2,5 @@
pub mod protocol; pub mod protocol;
#[cfg(feature = "prototype")] #[cfg(feature = "model")]
pub mod model; pub mod model;

View File

@ -24,7 +24,7 @@ pub use self::{
connect::Connect, connect::Connect,
dissociate::Dissociate, dissociate::Dissociate,
heartbeat::Heartbeat, heartbeat::Heartbeat,
packet::{Fragment, Packet}, packet::{Fragments, Packet},
}; };
pub struct Connection<B> { pub struct Connection<B> {
@ -352,7 +352,7 @@ where
} }
if self.buf[frag_id as usize].is_some() { if self.buf[frag_id as usize].is_some() {
return Err(AssembleError::DuplicateFragment); return Err(AssembleError::DuplicatedFragment);
} }
self.buf[frag_id as usize] = Some(data); self.buf[frag_id as usize] = Some(data);
@ -387,6 +387,6 @@ pub enum AssembleError {
InvalidFragmentId, InvalidFragmentId,
#[error("invalid address")] #[error("invalid address")]
InvalidAddress, InvalidAddress,
#[error("duplicate fragment")] #[error("duplicated fragment")]
DuplicateFragment, DuplicatedFragment,
} }

View File

@ -31,12 +31,12 @@ impl<B> Packet<side::Tx, B> {
} }
} }
pub fn into_fragments<'a, P>(self, payload: P) -> Fragment<'a, P> pub fn into_fragments<'a, P>(self, payload: P) -> Fragments<'a, P>
where where
P: AsRef<[u8]>, P: AsRef<[u8]>,
{ {
let Side::Tx(tx) = self.inner else { unreachable!() }; let Side::Tx(tx) = self.inner else { unreachable!() };
Fragment::new(tx.assoc_id, tx.pkt_id, tx.addr, tx.max_pkt_size, payload) Fragments::new(tx.assoc_id, tx.pkt_id, tx.addr, tx.max_pkt_size, payload)
} }
} }
@ -96,7 +96,7 @@ where
} }
} }
pub struct Fragment<'a, P> pub struct Fragments<'a, P>
where where
P: 'a, P: 'a,
{ {
@ -111,7 +111,7 @@ where
_marker: PhantomData<&'a P>, _marker: PhantomData<&'a P>,
} }
impl<'a, P> Fragment<'a, P> impl<'a, P> Fragments<'a, P>
where where
P: AsRef<[u8]> + 'a, P: AsRef<[u8]> + 'a,
{ {
@ -140,7 +140,7 @@ where
} }
} }
impl<'a, P> Iterator for Fragment<'a, P> impl<'a, P> Iterator for Fragments<'a, P>
where where
P: AsRef<[u8]> + 'a, P: AsRef<[u8]> + 'a,
{ {
@ -176,7 +176,7 @@ where
} }
} }
impl<P> ExactSizeIterator for Fragment<'_, P> impl<P> ExactSizeIterator for Fragments<'_, P>
where where
P: AsRef<[u8]>, P: AsRef<[u8]>,
{ {