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>
impl<'a> Value<'a>
Sourcepub fn as_str(self) -> Option<&'a str>
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.
Sourcepub fn eq_str(self, other: &str) -> bool
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.
Sourcepub fn semantic_eq(self, other: Value<'_>) -> bool
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.
Sourcepub const fn is_textual(self) -> bool
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.