#[non_exhaustive]pub enum OutboundPlain<'a> {
Single(&'a [u8]),
Multiple {
chunks: &'a [&'a [u8]],
start: usize,
end: usize,
},
}Expand description
A collection of borrowed plaintext slices.
Warning: OutboundPlain does not guarantee that the simplest variant is used. Multiple can hold non fragmented or empty payloads.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Single(&'a [u8])
A single byte slice.
Contrary to Multiple, this uses a single pointer indirection
Multiple
A collection of chunks (byte slices).
Implementations§
Source§impl<'a> OutboundPlain<'a>
impl<'a> OutboundPlain<'a>
Sourcepub fn new(chunks: &'a [&'a [u8]]) -> Self
pub fn new(chunks: &'a [&'a [u8]]) -> Self
Create a payload from a slice of byte slices. If fragmented the cursors are added by default: start = 0, end = length
Sourcepub fn copy_to_vec(&self, vec: &mut Vec<u8>)
pub fn copy_to_vec(&self, vec: &mut Vec<u8>)
Append all bytes to a vector
Sourcepub fn chunks(&self) -> impl Iterator<Item = &'a [u8]> + '_
pub fn chunks(&self) -> impl Iterator<Item = &'a [u8]> + '_
Iterate over the payload’s chunks of bytes, in order.
Empty chunks are not yielded.
Sourcepub fn single_chunk(&self) -> Option<&'a [u8]>
pub fn single_chunk(&self) -> Option<&'a [u8]>
The payload’s single contiguous chunk, or None if it is fragmented.
An empty payload is treated as a single empty chunk. A Self::Multiple
payload is contiguous when its selected range lies within one chunk.
Distinct chunks are never joined, even if their addresses are adjacent.