Skip to main content

ChunkedBytes

Struct ChunkedBytes 

Source
pub struct ChunkedBytes<C, const MAX: u32 = xdrs::::chunked::ChunkedBytes::{constant#0}>(pub C);
Expand description

Variable-length opaque data held as a sequence of byte chunks.

ChunkedBytes<C, MAX> is EncodesAs<BytesM<MAX>>. Each chunk is anything that is AsRef<[u8]>, such as a Vec<u8>, a &[u8] or an Arc<[u8]>, and is written straight from its buffer, followed by one TXS padding for the whole opaque. See the module documentation.

§Example

use xdrs::{BytesM, ChunkedBytes, txs};

let chunked = ChunkedBytes::<_>(vec![&b"hello, "[..], &b"world"[..]]);
let joined = BytesM::<{ u32::MAX }>(b"hello, world".to_vec());
assert_eq!(txs::encode(&chunked).unwrap(), txs::encode(&joined).unwrap());

Tuple Fields§

§0: C

Implementations§

Source§

impl<C, B, const MAX: u32> ChunkedBytes<C, MAX>
where C: Deref<Target = [B]>, B: AsRef<[u8]>,

Source

pub fn len(&self) -> usize

The total number of bytes across all chunks.

Source

pub fn is_empty(&self) -> bool

Whether every chunk is empty.

Trait Implementations§

Source§

impl<C, const MAX: u32> Clone for ChunkedBytes<C, MAX>
where C: Clone,

Source§

fn clone(&self) -> ChunkedBytes<C, MAX>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C, const MAX: u32> ConstMaxSize for ChunkedBytes<C, MAX>

Source§

const MAX_SIZE: Option<usize>

Worst-case CXS encoded size in bytes, or None if unbounded.
Source§

impl<C, const MAX: u32> ConstMaxSize for ChunkedBytes<C, MAX>

Source§

const MAX_SIZE: Option<usize>

Worst-case TXS encoded size in bytes, or None if unbounded.
Source§

impl<C, const MAX: u32> Copy for ChunkedBytes<C, MAX>
where C: Copy,

Source§

impl<C, const MAX: u32> Debug for ChunkedBytes<C, MAX>
where C: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<C, const MAX: u32> Default for ChunkedBytes<C, MAX>
where C: Default,

Source§

fn default() -> ChunkedBytes<C, MAX>

Returns the “default value” for a type. Read more
Source§

impl<C, B, const MAX: u32> EncodesAs<BytesM<MAX>> for ChunkedBytes<C, MAX>
where C: Deref<Target = [B]>, B: AsRef<[u8]>,

Source§

impl<C, B, const MAX: u32> EncodesAs<ChunkedBytes<C, MAX>> for ChunkedBytes<C, MAX>
where C: Deref<Target = [B]>, B: AsRef<[u8]>,

Source§

impl<C, const MAX: u32> Eq for ChunkedBytes<C, MAX>
where C: Eq,

Source§

impl<C, const MAX: u32> PartialEq for ChunkedBytes<C, MAX>
where C: PartialEq,

Source§

fn eq(&self, other: &ChunkedBytes<C, MAX>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C, const MAX: u32> StructuralPartialEq for ChunkedBytes<C, MAX>
where C: PartialEq,

Source§

impl<C, B, const MAX: u32> WriteXDR for ChunkedBytes<C, MAX>
where C: Deref<Target = [B]>, B: AsRef<[u8]>,

Source§

fn write_xdr<F, W>(&self, w: &mut W) -> Result<(), WriteError>
where W: Writer<F>,

Writes this value as XDR data to the writer. Read more
Source§

unsafe fn write_xdr_unchecked<F, W>(&self, w: &mut W)
where W: WriterUnchecked<F>,

Writes this value as XDR data to the writer, without runtime checks. Read more

Auto Trait Implementations§

§

impl<C, const MAX: u32> Freeze for ChunkedBytes<C, MAX>
where C: Freeze,

§

impl<C, const MAX: u32> RefUnwindSafe for ChunkedBytes<C, MAX>
where C: RefUnwindSafe,

§

impl<C, const MAX: u32> Send for ChunkedBytes<C, MAX>
where C: Send,

§

impl<C, const MAX: u32> Sync for ChunkedBytes<C, MAX>
where C: Sync,

§

impl<C, const MAX: u32> Unpin for ChunkedBytes<C, MAX>
where C: Unpin,

§

impl<C, const MAX: u32> UnsafeUnpin for ChunkedBytes<C, MAX>
where C: UnsafeUnpin,

§

impl<C, const MAX: u32> UnwindSafe for ChunkedBytes<C, MAX>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Hash for T
where T: WriteXDR,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.