pub enum BareItem {
Decimal(Decimal),
Integer(i64),
String(String),
ByteSeq(Vec<u8>),
Boolean(bool),
Token(String),
}
Expand description
BareItem
type is used to construct Items
or Parameters
values.
Variants§
Decimal(Decimal)
Decimal number
Integer(i64)
Integer number
String(String)
ByteSeq(Vec<u8>)
Boolean(bool)
Token(String)
Implementations§
source§impl BareItem
impl BareItem
sourcepub fn as_decimal(&self) -> Option<Decimal>
pub fn as_decimal(&self) -> Option<Decimal>
If BareItem
is a decimal, returns Decimal
, otherwise returns None
.
let decimal_number = Decimal::from_f64(415.566).unwrap();
let bare_item: BareItem = decimal_number.into();
assert_eq!(bare_item.as_decimal().unwrap(), decimal_number);
sourcepub fn as_int(&self) -> Option<i64>
pub fn as_int(&self) -> Option<i64>
If BareItem
is an integer, returns i64
, otherwise returns None
.
let bare_item: BareItem = 100.into();
assert_eq!(bare_item.as_int().unwrap(), 100);
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If BareItem
is String
, returns &str
, otherwise returns None
.
let bare_item = BareItem::String("foo".into());
assert_eq!(bare_item.as_str().unwrap(), "foo");
sourcepub fn as_byte_seq(&self) -> Option<&Vec<u8>>
pub fn as_byte_seq(&self) -> Option<&Vec<u8>>
If BareItem
is a ByteSeq
, returns &Vec<u8>
, otherwise returns None
.
let bare_item = BareItem::ByteSeq("foo".to_owned().into_bytes());
assert_eq!(bare_item.as_byte_seq().unwrap().as_slice(), "foo".as_bytes());
Trait Implementations§
source§impl PartialEq for BareItem
impl PartialEq for BareItem
impl StructuralPartialEq for BareItem
Auto Trait Implementations§
impl RefUnwindSafe for BareItem
impl Send for BareItem
impl Sync for BareItem
impl Unpin for BareItem
impl UnwindSafe for BareItem
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