pub enum Term {
}Expand description
Higher level Elixir types
These can be created by using the Term::from methods or creating them directly.
let string = Term::from("ok");
let atom = Term::Atom("ok".to_string());
assert!(string.is_string());
assert!(atom.is_atom());
assert_ne!(string, atom);The Term::as_* will unwrap the Term into a specific type if the Term is that type
let atom = Term::Atom("ok".to_string());
assert_eq!(Some("ok".to_string()), atom.as_atom());
let atom = Term::Atom("ok".to_string());
assert_eq!(None, atom.as_string());Convert to RawTerm
let term = Term::from("testing");
let raw_term = RawTerm::from(term);
assert_eq!(RawTerm::Binary(vec![116, 101, 115, 116, 105, 110, 103]), raw_term);Convert from RawTerm
let raw_term = RawTerm::Binary(vec![116, 101, 115, 116, 105, 110, 103]);
let term = Term::from(raw_term);
assert_eq!(Some("testing".to_string()), term.as_string());Variants§
Byte(u8)
Int(i32)
Float(OrderedFloat<f64>)
String(String)
Atom(String)
Bytes(Vec<u8>)
Bool(bool)
Nil
BigInt(BigInt)
Charlist(Vec<u8>)
Map(HashMap<Term, Term>)
Keyword(Keylist<String, Term>)
List(Vec<Term>)
Tuple(Vec<Term>)
Other(RawTerm)
Implementations§
Source§impl Term
impl Term
pub fn from_bytes(input: &[u8]) -> Result<Term, NomErr<Error<&[u8]>>>
pub fn to_bytes(self) -> Vec<u8> ⓘ
pub fn as_type(&self) -> RawTermType
pub fn as_general_type(&self) -> RawTermGeneralType
pub fn is_byte(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_atom(&self) -> bool
pub fn is_tuple(&self) -> bool
Sourcepub fn is_pair_tuple(&self) -> bool
pub fn is_pair_tuple(&self) -> bool
Check if the Term is a tuple of length 2
let term = Term::from((1, 2));
assert!(term.is_pair_tuple());pub fn is_list(&self) -> bool
Sourcepub fn is_string_tuple_pair(&self) -> bool
pub fn is_string_tuple_pair(&self) -> bool
Check if the Term is of the form ("string", any)
let term = Term::from(("test", 1));
assert!(term.is_string_tuple_pair());
let term = Term::from((1, 2));
assert!(!term.is_string_tuple_pair());pub fn as_bool(self) -> Option<bool>
pub fn as_nil(self) -> Option<()>
pub fn as_byte(self) -> Option<u8>
pub fn as_int(self) -> Option<i32>
pub fn as_float(self) -> Option<f64>
pub fn as_atom(self) -> Option<String>
pub fn as_string(self) -> Option<String>
pub fn as_bytes(self) -> Option<Vec<u8>>
pub fn as_charlist(self) -> Option<Vec<u8>>
pub fn as_big_int(self) -> Option<BigInt>
pub fn as_keyword(self) -> Option<Keylist<String, Term>>
pub fn as_list(self) -> Option<Vec<Term>>
pub fn as_tuple(self) -> Option<Vec<Term>>
pub fn as_map(self) -> Option<HashMap<Term, Term>>
Trait Implementations§
Source§impl<A, B, C, D> From<(A, B, C, D)> for Term
impl<A, B, C, D> From<(A, B, C, D)> for Term
Source§fn from(input: (A, B, C, D)) -> Self
fn from(input: (A, B, C, D)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E> From<(A, B, C, D, E)> for Term
impl<A, B, C, D, E> From<(A, B, C, D, E)> for Term
Source§fn from(input: (A, B, C, D, E)) -> Self
fn from(input: (A, B, C, D, E)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F> From<(A, B, C, D, E, F)> for Term
impl<A, B, C, D, E, F> From<(A, B, C, D, E, F)> for Term
Source§fn from(input: (A, B, C, D, E, F)) -> Self
fn from(input: (A, B, C, D, E, F)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G> From<(A, B, C, D, E, F, G)> for Term
impl<A, B, C, D, E, F, G> From<(A, B, C, D, E, F, G)> for Term
Source§fn from(input: (A, B, C, D, E, F, G)) -> Self
fn from(input: (A, B, C, D, E, F, G)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H> From<(A, B, C, D, E, F, G, H)> for Term
impl<A, B, C, D, E, F, G, H> From<(A, B, C, D, E, F, G, H)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H)) -> Self
fn from(input: (A, B, C, D, E, F, G, H)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I> From<(A, B, C, D, E, F, G, H, I)> for Term
impl<A, B, C, D, E, F, G, H, I> From<(A, B, C, D, E, F, G, H, I)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J> From<(A, B, C, D, E, F, G, H, I, J)> for Term
impl<A, B, C, D, E, F, G, H, I, J> From<(A, B, C, D, E, F, G, H, I, J)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J, K> From<(A, B, C, D, E, F, G, H, I, J, K)> for Term
impl<A, B, C, D, E, F, G, H, I, J, K> From<(A, B, C, D, E, F, G, H, I, J, K)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J, K)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J, K)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L> From<(A, B, C, D, E, F, G, H, I, J, K, L)> for Term
impl<A, B, C, D, E, F, G, H, I, J, K, L> From<(A, B, C, D, E, F, G, H, I, J, K, L)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L, M> From<(A, B, C, D, E, F, G, H, I, J, K, L, M)> for Term
impl<A, B, C, D, E, F, G, H, I, J, K, L, M> From<(A, B, C, D, E, F, G, H, I, J, K, L, M)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> From<(A, B, C, D, E, F, G, H, I, J, K, L, M, N)> for Term
impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> From<(A, B, C, D, E, F, G, H, I, J, K, L, M, N)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M, N)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M, N)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> From<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)> for Term
impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> From<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)) -> Self
Converts to this type from the input type.
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> From<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)> for Term
impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> From<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)> for Term
Source§fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)) -> Self
fn from(input: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)) -> Self
Converts to this type from the input type.
Source§impl Ord for Term
impl Ord for Term
Source§impl PartialOrd for Term
impl PartialOrd for Term
impl Eq for Term
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnwindSafe for Term
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