pub enum BareItem<'a> {
Integer(i64),
Decimal(Decimal),
String(SfString<'a>),
Token(&'a str),
ByteSeq(ByteSeq<'a>),
Boolean(bool),
Date(i64),
DisplayString(DisplayString<'a>),
}Expand description
A bare item (RFC 9651 section 3.3).
§Examples
use parse_net::sfv::{self, BareItem};
assert_eq!(sfv::parse_item(b"42")?.bare, BareItem::Integer(42));
assert_eq!(sfv::parse_item(b"abc")?.bare, BareItem::Token("abc"));
assert!(matches!(sfv::parse_item(b"\"hi\"")?.bare, BareItem::String(s) if s.eq_str("hi")));Variants§
Integer(i64)
An Integer, at most 15 digits.
Decimal(Decimal)
A Decimal, in thousandths.
String(SfString<'a>)
A String.
Token(&'a str)
A Token (ASCII by construction).
ByteSeq(ByteSeq<'a>)
A Byte Sequence, still base64.
Boolean(bool)
A Boolean.
Date(i64)
A Date: seconds since the Unix epoch, within years 1 to 9999.
DisplayString(DisplayString<'a>)
A Display String, still percent-encoded.
Implementations§
Source§impl BareItem<'_>
impl BareItem<'_>
Sourcepub fn to_owned(&self) -> OwnedBareItem
Available on crate feature alloc only.
pub fn to_owned(&self) -> OwnedBareItem
alloc only.Copies the bare item (one allocation for a text kind, none otherwise).
§Examples
use parse_net::sfv::{self, BareItem};
let bare = sfv::parse_item(b"\"hi\"")?.bare;
assert_eq!(bare.to_owned().as_view(), bare);Trait Implementations§
impl<'a> Copy for BareItem<'a>
impl<'a> Eq for BareItem<'a>
impl<'a> StructuralPartialEq for BareItem<'a>
Auto Trait Implementations§
impl<'a> Freeze for BareItem<'a>
impl<'a> RefUnwindSafe for BareItem<'a>
impl<'a> Send for BareItem<'a>
impl<'a> Sync for BareItem<'a>
impl<'a> Unpin for BareItem<'a>
impl<'a> UnsafeUnpin for BareItem<'a>
impl<'a> UnwindSafe for BareItem<'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