Struct veilid_tools::AssemblyBuffer
source · pub struct AssemblyBuffer { /* private fields */ }
Expand description
Packet reassembly and fragmentation handler
Used to provide, for raw unordered protocols such as UDP, a means to achieve:
- Fragmentation of packets to ensure they are smaller than a common MTU
- Reassembly of fragments upon receipt accounting for:
- duplication
- drops
- overlaps
AssemblyBuffer does not try to replicate TCP or other highly reliable protocols. Here are some of the design limitations to be aware of when using AssemblyBuffer:
- No packet acknowledgment. The sender does not know if a packet was received.
- No flow control. If there are buffering problems or drops, the sender and receiver have no protocol to address this.
- No retries or retransmission.
- No sequencing of packets. Packets may still be delivered to the application out of order, but this guarantees that only whole packets will be delivered if all of their fragments are received.
Implementations§
source§impl AssemblyBuffer
impl AssemblyBuffer
pub fn new() -> Self
sourcepub fn insert_frame(
&self,
frame: &[u8],
remote_addr: SocketAddr
) -> NetworkResult<Option<Vec<u8>>>
pub fn insert_frame( &self, frame: &[u8], remote_addr: SocketAddr ) -> NetworkResult<Option<Vec<u8>>>
Receive a packet chunk and add to the message assembly if a message has been completely, return it
sourcepub async fn split_message<S, F>(
&self,
data: Vec<u8>,
remote_addr: SocketAddr,
sender: S
) -> Result<NetworkResult<()>>
pub async fn split_message<S, F>( &self, data: Vec<u8>, remote_addr: SocketAddr, sender: S ) -> Result<NetworkResult<()>>
Split a message into packets and send them serially, ensuring that they are sent consecutively to a particular remote address, never interleaving packets from one message and another to minimize reassembly problems
Trait Implementations§
source§impl Clone for AssemblyBuffer
impl Clone for AssemblyBuffer
source§fn clone(&self) -> AssemblyBuffer
fn clone(&self) -> AssemblyBuffer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for AssemblyBuffer
impl !RefUnwindSafe for AssemblyBuffer
impl Send for AssemblyBuffer
impl Sync for AssemblyBuffer
impl Unpin for AssemblyBuffer
impl !UnwindSafe for AssemblyBuffer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more