pub struct ChunkList(/* private fields */);Expand description
Sender side: an ordered list of Chunks for one message. Build it from the payload with
ChunkList::split, passing the per-message data size to cut at (the connection’s negotiated
max_message_size minus the envelope reserve), then iterate (or convert to Vec<Chunk>) to put
each chunk on the wire. The cut size is a runtime argument rather than a type parameter because
it is decided per connection from the negotiated limit. Reassembly is the receiver’s job — see
MessageReassembler.
Implementations§
Source§impl ChunkList
impl ChunkList
Sourcepub fn split(bytes: &Bytes, chunk_size: usize) -> Self
pub fn split(bytes: &Bytes, chunk_size: usize) -> Self
Eagerly split bytes into chunks of at most chunk_size data bytes each, tagged
[i, total]. A test/helper constructor (the production send path uses
stream, and WireReserves::plan never yields an unusable chunk_size —
it returns None instead). chunk_size is clamped to ≥ 1 only as a defensive guard against
a caller passing 0; it is not a sanctioned way to produce 1-byte chunks on the wire.
Sourcepub fn stream(bytes: Bytes, chunk_size: usize) -> impl Iterator<Item = Chunk>
pub fn stream(bytes: Bytes, chunk_size: usize) -> impl Iterator<Item = Chunk>
Stream bytes into chunks of at most chunk_size data bytes each without materializing
the whole list: each chunk’s data is a zero-copy Bytes::slice of the input, and the
chunks are yielded lazily, so a sender can frame and flush one chunk at a time with bounded
memory (rather than allocating every chunk up front). All chunks share one [i, total]
numbering and one ChunkMeta. chunk_size is clamped to ≥ 1 so a degenerate value still
terminates; empty input yields no chunks, agreeing with split.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ChunkList
impl<'de> Deserialize<'de> for ChunkList
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl IntoIterator for &ChunkList
impl IntoIterator for &ChunkList
Source§impl IntoIterator for ChunkList
impl IntoIterator for ChunkList
Auto Trait Implementations§
impl Freeze for ChunkList
impl RefUnwindSafe for ChunkList
impl Send for ChunkList
impl Sync for ChunkList
impl Unpin for ChunkList
impl UnsafeUnpin for ChunkList
impl UnwindSafe for ChunkList
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.