Skip to main content

NetnodeBytes

Struct NetnodeBytes 

Source
pub struct NetnodeBytes<'a>(/* private fields */);
Expand description

A byte slice validated against the SDK’s 1..=MAXSPECSIZE object-size domain.

Accepted by every netnode byte setter, on both NetnodeMut and its Tag-scoped twin TaggedNetnodeMut.

use idakit::netnode::{NetnodeBytes, NetnodeBytesError};

assert!(matches!(
    NetnodeBytes::try_from(b"".as_slice()),
    Err(NetnodeBytesError::Empty)
));

let over_cap = vec![0u8; NetnodeBytes::MAX_SIZE + 1];
assert!(matches!(
    NetnodeBytes::try_from(&over_cap),
    Err(NetnodeBytesError::TooLarge { len, cap })
        if len == over_cap.len() && cap == NetnodeBytes::MAX_SIZE
));

let ok = NetnodeBytes::try_from(b"hi".as_slice()).unwrap();
assert_eq!(ok.as_bytes(), b"hi");

Implementations§

Source§

impl<'a> NetnodeBytes<'a>

Source

pub const MAX_SIZE: usize = idakit_sys::MAXSPECSIZE

The largest number of bytes the SDK accepts for one value/supval/hash object.

Source

pub const fn as_bytes(self) -> &'a [u8]

The validated bytes.

Trait Implementations§

Source§

impl<'a> Clone for NetnodeBytes<'a>

Source§

fn clone(&self) -> NetnodeBytes<'a>

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<'a> Copy for NetnodeBytes<'a>

Source§

impl Debug for NetnodeBytes<'_>

Source§

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

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

impl<'a> TryFrom<&'a Vec<u8>> for NetnodeBytes<'a>

Source§

type Error = NetnodeBytesError

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

fn try_from(value: &'a Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, const N: usize> TryFrom<&'a [u8; N]> for NetnodeBytes<'a>

Source§

type Error = NetnodeBytesError

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

fn try_from(value: &'a [u8; N]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a [u8]> for NetnodeBytes<'a>

Source§

type Error = NetnodeBytesError

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

fn try_from(value: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for NetnodeBytes<'a>

§

impl<'a> RefUnwindSafe for NetnodeBytes<'a>

§

impl<'a> Send for NetnodeBytes<'a>

§

impl<'a> Sync for NetnodeBytes<'a>

§

impl<'a> Unpin for NetnodeBytes<'a>

§

impl<'a> UnsafeUnpin for NetnodeBytes<'a>

§

impl<'a> UnwindSafe for NetnodeBytes<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more