Skip to main content

AttrParserRef

Struct AttrParserRef 

Source
pub struct AttrParserRef<'a> {
    pub attrs: &'a [(Cow<'a, str>, ValueRef<'a>)],
    pub errors: Vec<BinaryError>,
}

Fields§

§attrs: &'a [(Cow<'a, str>, ValueRef<'a>)]§errors: Vec<BinaryError>

Implementations§

Source§

impl<'a> AttrParserRef<'a>

Source

pub fn new(node: &'a NodeRef<'a>) -> Self

Source

pub fn ok(&self) -> bool

Source

pub fn finish(&self) -> Result<()>

Source

pub fn optional_string(&mut self, key: &str) -> Option<Cow<'a, str>>

Get string from the value. Works for both String and JID variants.

  • String variant: Cow::Borrowed — zero copy
  • JID variant: Cow::Owned — allocates only when needed
Source

pub fn required_string(&mut self, key: &str) -> Result<Cow<'a, str>>

Get a required string attribute, returning an error if missing.

Prefer this over string() for required attributes as it makes the error explicit rather than silently defaulting to empty string.

Source

pub fn optional_jid(&mut self, key: &str) -> Option<Jid>

Get JID from the value. If the value is a JidRef, returns it directly without parsing (zero allocation). If the value is a string, parses it as a JID.

Source

pub fn jid(&mut self, key: &str) -> Jid

Source

pub fn non_ad_jid(&mut self, key: &str) -> Jid

Source

pub fn optional_bool(&mut self, key: &str) -> bool

Source

pub fn bool(&mut self, key: &str) -> bool

Source

pub fn optional_u64(&mut self, key: &str) -> Option<u64>

Source

pub fn unix_time(&mut self, key: &str) -> i64

Source

pub fn optional_unix_time(&mut self, key: &str) -> Option<i64>

Source

pub fn unix_milli(&mut self, key: &str) -> i64

Source

pub fn optional_unix_milli(&mut self, key: &str) -> Option<i64>

Auto Trait Implementations§

§

impl<'a> Freeze for AttrParserRef<'a>

§

impl<'a> !RefUnwindSafe for AttrParserRef<'a>

§

impl<'a> Send for AttrParserRef<'a>

§

impl<'a> Sync for AttrParserRef<'a>

§

impl<'a> Unpin for AttrParserRef<'a>

§

impl<'a> UnsafeUnpin for AttrParserRef<'a>

§

impl<'a> !UnwindSafe for AttrParserRef<'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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.