Struct NsPayload

Source
pub struct NsPayload(pub(crate) [u8]);
Expand description

Raw binary data for a single namespace’s payload.

Any sequence of bytes is a valid NsPayload.

See module-level documentation types for a full specification of the binary format of a namespace.

Tuple Fields§

§0: [u8]

Implementations§

Source§

impl NsPayload

Source

pub(super) fn new_private(p: &[u8]) -> &NsPayload

Source§

impl NsPayload

Source

pub fn from_bytes_slice(bytes: &[u8]) -> &NsPayload

Source

pub fn as_bytes_slice(&self) -> &[u8]

Source

pub fn byte_len(&self) -> NsPayloadByteLen

Source

pub fn read<'a, R>(&'a self, range: &R) -> R::Output
where R: NsPayloadBytesRange<'a>,

Read and parse bytes from the ns payload.

Arg range: &R is convertible into a Range<usize> via NsPayloadBytesRange. The payload bytes are parsed into a R::Output via FromNsPayloadBytes.

Source

pub fn iter(&self) -> TxIter

Iterator over all transactions in this namespace.

Source

pub fn export_all_txs(&self, ns_id: &NamespaceId) -> Vec<Transaction>

Return all transactions in this namespace. The namespace ID for each returned Transaction is set to ns_id.

Source

pub fn export_tx( &self, ns_id: &NamespaceId, index: &TxIndex, ) -> Option<Transaction>

Return a transaction from this namespace. Set its namespace ID to ns_id.

Return None if index is out of bounds.

Source

fn read_num_txs(&self) -> NumTxsUnchecked

Private helper. (Could be pub if desired.)

Source

fn iter_from_num_txs(&self, num_txs: &NumTxsUnchecked) -> TxIter

Private helper

Source

fn tx_from_num_txs( &self, ns_id: &NamespaceId, index: &TxIndex, num_txs_unchecked: &NumTxsUnchecked, ) -> Transaction

Private helper

Trait Implementations§

Source§

impl Borrow<NsPayload> for NsPayloadOwned

Source§

fn borrow(&self) -> &NsPayload

Immutably borrows from an owned value. Read more
Source§

impl ToOwned for NsPayload

Source§

type Owned = NsPayloadOwned

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> NsPayloadOwned

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

fn clone_into(&self, target: &mut Self::Owned)

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

Auto Trait Implementations§

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
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.