Skip to main content

Value

Enum Value 

Source
pub enum Value<'a> {
    Nil,
    Token(&'a str),
    Bytes(&'a [u8]),
    Packed(Packed<'a>),
    Jid(Jid<'a>),
}
Expand description

A scalar read from a frame.

Variants§

§

Nil

An absent value.

§

Token(&'a str)

A token resolved through the table.

§

Bytes(&'a [u8])

Raw bytes. Text in an attribute position, opaque in a content position.

§

Packed(Packed<'a>)

A packed nibble or hex run.

§

Jid(Jid<'a>)

A JID, held as parts.

Implementations§

Source§

impl<'a> Value<'a>

Source

pub const fn is_nil(self) -> bool

Whether this is the absent value.

Source

pub fn as_str(self) -> Option<&'a str>

The value as a borrowed string, when one exists in the frame already.

Returns None for packed runs and JIDs — not because they are not textual, but because their text exists nowhere to borrow from. Use eq_str to compare them, or Display to render them.

Source

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

The value’s bytes, when it is raw.

Source

pub const fn as_jid(self) -> Option<Jid<'a>>

The JID, if this is one.

Source

pub const fn as_packed(self) -> Option<Packed<'a>>

The packed run, if this is one.

Source

pub fn eq_str(self, other: &str) -> bool

Whether the value renders as exactly other, without building a string.

This is the comparison L1 derivation actually needs — attrs["type"] == "text" and the like — so it must not allocate.

Source

pub fn semantic_eq(self, other: Value<'_>) -> bool

Whether two values mean the same thing, whatever form each arrived in.

This is the comparison a conformance run needs. Two engines can encode one value differently and both be right — a token here, the same text as bytes there — and calling that a divergence would bury the real ones.

Source

pub const fn is_textual(self) -> bool

Whether the value is textual in the sense the protocol means: anything that appears in an attribute position.

Trait Implementations§

Source§

impl<'a> Clone for Value<'a>

Source§

fn clone(&self) -> Self

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 Value<'a>

Source§

impl<'a> Debug for Value<'a>

Source§

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

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

impl Display for Value<'_>

Source§

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

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

impl<'a> Eq for Value<'a>

Source§

impl<'a> PartialEq for Value<'a>

Source§

fn eq(&self, other: &Self) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Value<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Value<'a>

§

impl<'a> RefUnwindSafe for Value<'a>

§

impl<'a> Send for Value<'a>

§

impl<'a> Sync for Value<'a>

§

impl<'a> Unpin for Value<'a>

§

impl<'a> UnsafeUnpin for Value<'a>

§

impl<'a> UnwindSafe for Value<'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, 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, 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.