Struct sbp::SbpString

source ·
pub struct SbpString<T, E = Unterminated> { /* private fields */ }
Expand description

Fixed or variable length string and its encoding.

Implementations§

source§

impl<T, E> SbpString<T, E>
where T: AsRef<[u8]>,

source

pub fn new(data: T) -> Self

Creates a new SbpString with a given encoding. Does not check validity of data with encoding.

source

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

Returns a byte slice of this SbpString’s contents.

source

pub fn to_vec(&self) -> Vec<u8>

Returns a byte vector of this SbpString’s contents.

source§

impl<T: AsRef<[u8]>> SbpString<T, Unterminated>

source

pub fn unterminated(data: T) -> Self

Checked unterminated SbpString builder,

source§

impl<T: AsRef<[u8]>> SbpString<T, NullTerminated>

source§

impl SbpString<Vec<u8>, Multipart>

source

pub fn multipart(data: impl Into<Vec<u8>>) -> Result<Self, MultipartError>

source

pub fn from_parts(parts: impl IntoIterator<Item = impl AsRef<[u8]>>) -> Self

Unchecked from parts builder to construct Multipart SbpString

source

pub fn parts(&self) -> Parts<'_>

Returns an iterator over the parts of the string.

source§

impl SbpString<Vec<u8>, DoubleNullTerminated>

source

pub fn double_null_terminated( data: impl Into<Vec<u8>> ) -> Result<Self, DoubleNullTerminatedError>

source

pub fn from_parts(parts: impl IntoIterator<Item = impl AsRef<[u8]>>) -> Self

source

pub fn parts(&self) -> Parts<'_>

Returns an iterator over the parts of the string.

Trait Implementations§

source§

impl<T: Clone, E: Clone> Clone for SbpString<T, E>

source§

fn clone(&self) -> SbpString<T, E>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug, E: Debug> Debug for SbpString<T, E>

source§

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

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

impl<'de, E, const LEN: usize> Deserialize<'de> for SbpString<[u8; LEN], E>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de, E> Deserialize<'de> for SbpString<Vec<u8>, E>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T, E> Display for SbpString<T, E>
where T: AsRef<[u8]>,

source§

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

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

impl<E> From<String> for SbpString<Vec<u8>, E>

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl<E> From<Vec<u8>> for SbpString<Vec<u8>, E>

source§

fn from(v: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl<T: PartialEq, E: PartialEq> PartialEq for SbpString<T, E>

source§

fn eq(&self, other: &SbpString<T, E>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, E> Serialize for SbpString<T, E>
where T: AsRef<[u8]>,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Eq, E: Eq> Eq for SbpString<T, E>

source§

impl<T, E> StructuralPartialEq for SbpString<T, E>

Auto Trait Implementations§

§

impl<T, E> Freeze for SbpString<T, E>
where T: Freeze,

§

impl<T, E> RefUnwindSafe for SbpString<T, E>

§

impl<T, E> Send for SbpString<T, E>
where E: Send, T: Send,

§

impl<T, E> Sync for SbpString<T, E>
where E: Sync, T: Sync,

§

impl<T, E> Unpin for SbpString<T, E>
where E: Unpin, T: Unpin,

§

impl<T, E> UnwindSafe for SbpString<T, E>
where E: UnwindSafe, T: 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,