pub enum ValueRef<'a> {
String(NodeStr<'a>),
Jid(JidRef<'a>),
}Expand description
A decoded attribute value that can be either a string or a structured JID. This avoids string allocation when decoding JID tokens - the JidRef is returned directly and only converted to a string when actually needed.
Variants§
Implementations§
Source§impl<'a> ValueRef<'a>
impl<'a> ValueRef<'a>
Sourcepub fn encode_value<W: ByteWriter>(
&self,
encoder: &mut Encoder<'_, W>,
) -> Result<()>
pub fn encode_value<W: ByteWriter>( &self, encoder: &mut Encoder<'_, W>, ) -> Result<()>
Encode this value directly to the binary encoder.
Sourcepub fn as_str(&self) -> Cow<'_, str>
pub fn as_str(&self) -> Cow<'_, str>
String view of the value. Borrows from self.
- String variant: borrows the inner str — zero copy
- Jid variant: Cow::Owned — allocates only when needed
Sourcepub fn to_node_value(&self) -> NodeValue
pub fn to_node_value(&self) -> NodeValue
Convert to an owned NodeValue, preserving the variant (JID stays JID).
Trait Implementations§
Source§impl<'a> PartialEq for ValueRef<'a>
impl<'a> PartialEq for ValueRef<'a>
Source§impl<'yoke> Yokeable<'yoke> for ValueRef<'static>
impl<'yoke> Yokeable<'yoke> for ValueRef<'static>
Source§type Output = ValueRef<'yoke>
type Output = ValueRef<'yoke>
This type MUST be
Self with the 'static replaced with 'a, i.e. Self<'a>Source§fn transform_owned(self) -> Self::Output
fn transform_owned(self) -> Self::Output
impl<'a> StructuralPartialEq for ValueRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for ValueRef<'a>
impl<'a> RefUnwindSafe for ValueRef<'a>
impl<'a> Send for ValueRef<'a>
impl<'a> Sync for ValueRef<'a>
impl<'a> Unpin for ValueRef<'a>
impl<'a> UnsafeUnpin for ValueRef<'a>
impl<'a> UnwindSafe for ValueRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more