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;
#[cfg(feature = "prototype")]
#[cfg(feature = "model")]
pub mod model;

View File

@ -24,7 +24,7 @@ pub use self::{
connect::Connect,
dissociate::Dissociate,
heartbeat::Heartbeat,
packet::{Fragment, Packet},
packet::{Fragments, Packet},
};
pub struct Connection<B> {
@ -352,7 +352,7 @@ where
}
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);
@ -387,6 +387,6 @@ pub enum AssembleError {
InvalidFragmentId,
#[error("invalid address")]
InvalidAddress,
#[error("duplicate fragment")]
DuplicateFragment,
#[error("duplicated fragment")]
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
P: AsRef<[u8]>,
{
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
P: 'a,
{
@ -111,7 +111,7 @@ where
_marker: PhantomData<&'a P>,
}
impl<'a, P> Fragment<'a, P>
impl<'a, P> Fragments<'a, P>
where
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
P: AsRef<[u8]> + 'a,
{
@ -176,7 +176,7 @@ where
}
}
impl<P> ExactSizeIterator for Fragment<'_, P>
impl<P> ExactSizeIterator for Fragments<'_, P>
where
P: AsRef<[u8]>,
{