Enum foundation_ur::UR

source ·
pub enum UR<'a> {
    SinglePart {
        ur_type: &'a str,
        message: &'a str,
    },
    SinglePartDeserialized {
        ur_type: &'a str,
        message: &'a [u8],
    },
    MultiPart {
        ur_type: &'a str,
        fragment: &'a str,
        sequence: u32,
        sequence_count: u32,
    },
    MultiPartDeserialized {
        ur_type: &'a str,
        fragment: Part<'a>,
    },
}
Expand description

An uniform resource.

Variants§

§

SinglePart

A single-part resource.

Fields

§ur_type: &'a str

The type.

§message: &'a str

The message.

§

SinglePartDeserialized

A deserialized single-part resource.

Fields

§ur_type: &'a str

The type.

§message: &'a [u8]

The message.

§

MultiPart

A multiple-part resource.

Fields

§ur_type: &'a str

The type.

§fragment: &'a str

The fragment.

§sequence: u32

The sequence number.

§sequence_count: u32

The total sequence count.

§

MultiPartDeserialized

A deserialized multiple-part resource.

Fields

§ur_type: &'a str

The type.

§fragment: Part<'a>

The fragment.

Implementations§

source§

impl<'a> UR<'a>

source

pub fn new(ur_type: &'a str, message: &'a [u8]) -> Self

Construct a new single-part UR.

source

pub fn parse(s: &'a str) -> Result<Self, ParseURError>

Parses an uniform resource string.

Keep in mind, this does not deserialize the bytewords payload, deserialization is performed separately, for example, by the decoder.

source

pub fn is_single_part(&self) -> bool

Returns true if the Uniform Resource is single-part.

source

pub fn is_multi_part(&self) -> bool

Returns true if the Uniform Resource is multi-part.

source

pub fn is_deserialized(&self) -> bool

Returns true if this Uniform Resource is multi-part and deserialized.

source

pub fn as_type(&self) -> &str

Returns the UR type.

source

pub fn as_bytewords(&self) -> Option<&str>

Returns Some(bytewords) if the Uniform Resource is serialized.

source

pub fn as_part(&self) -> Option<&Part<'_>>

Returns Some(part) if the Uniform Resource is multi-part and is deserialized.

source

pub fn sequence(&self) -> Option<u32>

Returns Some(n) where n is the sequence number if the Uniform Resource is multi part.

source

pub fn sequence_count(&self) -> Option<u32>

Returns Some(n) where n is the sequence count if the Uniform Resource is multi part.

Trait Implementations§

source§

impl<'a> Clone for UR<'a>

source§

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

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<'a> Debug for UR<'a>

source§

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

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

impl<'a> Display for UR<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for UR<'a>

§

impl<'a> RefUnwindSafe for UR<'a>

§

impl<'a> Send for UR<'a>

§

impl<'a> Sync for UR<'a>

§

impl<'a> Unpin for UR<'a>

§

impl<'a> UnwindSafe for UR<'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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.