pub enum OwnedTerm {
Show 17 variants
Atom(Atom),
Integer(i64),
Float(f64),
Pid(ExternalPid),
Port(ExternalPort),
Reference(ExternalReference),
Binary(Vec<u8>),
BitBinary {
bytes: Vec<u8>,
bits: u8,
},
String(String),
List(Vec<OwnedTerm>),
ImproperList {
elements: Vec<OwnedTerm>,
tail: Box<OwnedTerm>,
},
Map(BTreeMap<OwnedTerm, OwnedTerm>),
Tuple(Vec<OwnedTerm>),
BigInt(BigInt),
ExternalFun(ExternalFun),
InternalFun(Box<InternalFun>),
Nil,
}Variants§
Atom(Atom)
Integer(i64)
Float(f64)
Pid(ExternalPid)
Port(ExternalPort)
Reference(ExternalReference)
Binary(Vec<u8>)
BitBinary
String(String)
List(Vec<OwnedTerm>)
ImproperList
Map(BTreeMap<OwnedTerm, OwnedTerm>)
Tuple(Vec<OwnedTerm>)
BigInt(BigInt)
ExternalFun(ExternalFun)
InternalFun(Box<InternalFun>)
Nil
Implementations§
Source§impl OwnedTerm
impl OwnedTerm
pub fn atom<S>(name: S) -> OwnedTerm
pub fn integer(value: i64) -> OwnedTerm
pub fn float(value: f64) -> OwnedTerm
pub fn binary(data: Vec<u8>) -> OwnedTerm
pub fn string<S>(value: S) -> OwnedTerm
pub fn list(elements: Vec<OwnedTerm>) -> OwnedTerm
pub fn improper_list(elements: Vec<OwnedTerm>, tail: OwnedTerm) -> OwnedTerm
pub fn map(entries: BTreeMap<OwnedTerm, OwnedTerm>) -> OwnedTerm
pub fn tuple(elements: Vec<OwnedTerm>) -> OwnedTerm
pub fn boolean(value: bool) -> OwnedTerm
pub fn ok() -> OwnedTerm
pub fn error() -> OwnedTerm
pub fn ok_tuple(value: OwnedTerm) -> OwnedTerm
pub fn error_tuple(reason: OwnedTerm) -> OwnedTerm
pub fn nil() -> OwnedTerm
pub fn is_atom(&self) -> bool
pub fn is_integer(&self) -> bool
pub fn is_list(&self) -> bool
pub fn is_map(&self) -> bool
pub fn is_tuple(&self) -> bool
pub fn as_atom(&self) -> Option<&Atom>
pub fn as_integer(&self) -> Option<i64>
pub fn as_float(&self) -> Option<f64>
pub fn as_binary(&self) -> Option<&[u8]>
pub fn as_string(&self) -> Option<&str>
pub fn as_list(&self) -> Option<&[OwnedTerm]>
pub fn as_map(&self) -> Option<&BTreeMap<OwnedTerm, OwnedTerm>>
pub fn as_tuple(&self) -> Option<&[OwnedTerm]>
pub fn as_list_mut(&mut self) -> Option<&mut Vec<OwnedTerm>>
pub fn as_map_mut(&mut self) -> Option<&mut BTreeMap<OwnedTerm, OwnedTerm>>
pub fn as_tuple_mut(&mut self) -> Option<&mut Vec<OwnedTerm>>
pub fn as_binary_mut(&mut self) -> Option<&mut Vec<u8>>
pub fn try_as_integer(&self) -> Result<i64, TermConversionError>
pub fn try_as_float(&self) -> Result<f64, TermConversionError>
pub fn try_as_atom(&self) -> Result<&Atom, TermConversionError>
pub fn try_as_binary(&self) -> Result<&[u8], TermConversionError>
pub fn try_as_string(&self) -> Result<&str, TermConversionError>
pub fn try_as_list(&self) -> Result<&[OwnedTerm], TermConversionError>
pub fn try_as_tuple(&self) -> Result<&[OwnedTerm], TermConversionError>
pub fn try_as_map( &self, ) -> Result<&BTreeMap<OwnedTerm, OwnedTerm>, TermConversionError>
pub fn into_map_iter( self, ) -> Result<impl Iterator<Item = (OwnedTerm, OwnedTerm)>, TermConversionError>
pub fn type_name(&self) -> &'static str
pub fn atom_name(&self) -> Option<&str>
pub fn is_atom_with_name(&self, name: &str) -> bool
pub fn is_true(&self) -> bool
pub fn is_false(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_nil_atom(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn into_ok_value(self) -> Option<OwnedTerm>
pub fn into_rex_response(self) -> Result<OwnedTerm, TermConversionError>
pub fn into_error_reason(self) -> Option<OwnedTerm>
pub fn map_get(&self, key: &OwnedTerm) -> Option<&OwnedTerm>
pub fn get<I>(&self, index: I) -> Option<&OwnedTerm>where
I: TermIndex,
pub fn iter(&self) -> OwnedTermIter<'_>
pub fn proplist_get_atom_key(&self, key: &str) -> Option<&OwnedTerm>
pub fn is_proplist(&self) -> bool
pub fn is_proplist_element(element: &OwnedTerm) -> bool
pub fn normalize_proplist(&self) -> Result<OwnedTerm, TermConversionError>
pub fn proplist_to_map(&self) -> Result<OwnedTerm, TermConversionError>
pub fn map_to_proplist(&self) -> Result<OwnedTerm, TermConversionError>
pub fn to_map_recursive(&self) -> Result<OwnedTerm, TermConversionError>
pub fn atomize_keys(&self) -> Result<OwnedTerm, TermConversionError>
pub fn as_list_wrapped(&self) -> OwnedTerm
pub fn proplist_iter(&self) -> Option<ProplistIter<'_>>
pub fn map_get_atom_key(&self, key: &str) -> Option<&OwnedTerm>
pub fn map_get_i64(&self, key: &str) -> Option<i64>
pub fn map_get_i64_or(&self, key: &str, default: i64) -> i64
pub fn map_get_bool(&self, key: &str) -> Option<bool>
pub fn map_get_bool_or(&self, key: &str, default: bool) -> bool
pub fn map_get_atom(&self, key: &str) -> Option<&Atom>
pub fn map_get_string(&self, key: &str) -> Option<String>
pub fn map_get_string_or(&self, key: &str, default: &str) -> String
pub fn map_get_pid(&self, key: &str) -> Option<&ExternalPid>
pub fn map_get_atom_string(&self, key: &str) -> Option<String>
pub fn map_get_atom_string_or(&self, key: &str, default: &str) -> String
pub fn map_get_pid_string(&self, key: &str) -> Option<String>
pub fn map_get_pid_string_or(&self, key: &str, default: &str) -> String
pub fn map_get_mfa_string(&self, key: &str) -> Option<String>
pub fn map_get_mfa_string_or(&self, key: &str, default: &str) -> String
pub fn as_erlang_string(&self) -> Option<String>
pub fn as_erlang_string_or(&self, default: &str) -> String
pub fn tuple_get(&self, index: usize) -> Option<&OwnedTerm>
pub fn tuple_get_string(&self, index: usize) -> Option<String>
pub fn tuple_get_string_or(&self, index: usize, default: &str) -> String
pub fn tuple_get_atom_string(&self, index: usize) -> Option<String>
pub fn tuple_get_atom_string_or(&self, index: usize, default: &str) -> String
pub fn charlist<S>(s: S) -> OwnedTerm
pub fn is_charlist(&self) -> bool
pub fn as_charlist_string(&self) -> Option<String>
pub fn as_list_or_empty(&self) -> &[OwnedTerm]
pub fn try_as_mfa(&self) -> Option<Mfa>
pub fn format_as_mfa(&self) -> Option<String>
pub fn as_pid(&self) -> Option<&ExternalPid>
pub fn try_as_pid(&self) -> Result<&ExternalPid, TermConversionError>
pub fn is_pid(&self) -> bool
pub fn format_as_pid(&self) -> Option<String>
pub fn proplist_get_i64(&self, key: &str) -> Option<i64>
pub fn proplist_get_i64_or(&self, key: &str, default: i64) -> i64
pub fn proplist_get_bool(&self, key: &str) -> Option<bool>
pub fn proplist_get_bool_or(&self, key: &str, default: bool) -> bool
pub fn proplist_get_atom(&self, key: &str) -> Option<&Atom>
pub fn proplist_get_string(&self, key: &str) -> Option<String>
pub fn proplist_get_string_or(&self, key: &str, default: &str) -> String
pub fn proplist_get_pid(&self, key: &str) -> Option<&ExternalPid>
pub fn proplist_get_atom_string(&self, key: &str) -> Option<String>
pub fn proplist_get_atom_string_or(&self, key: &str, default: &str) -> String
pub fn proplist_get_pid_string(&self, key: &str) -> Option<String>
pub fn proplist_get_pid_string_or(&self, key: &str, default: &str) -> String
pub fn proplist_get_mfa_string(&self, key: &str) -> Option<String>
pub fn proplist_get_mfa_string_or(&self, key: &str, default: &str) -> String
pub fn atom_list(names: &[&str]) -> OwnedTerm
pub fn map_iter(&self) -> Option<impl Iterator<Item = (&OwnedTerm, &OwnedTerm)>>
pub fn try_into_list(self) -> Result<Vec<OwnedTerm>, TermConversionError>
pub fn try_into_tuple(self) -> Result<Vec<OwnedTerm>, TermConversionError>
pub fn try_into_map( self, ) -> Result<BTreeMap<OwnedTerm, OwnedTerm>, TermConversionError>
pub fn try_into_binary(self) -> Result<Vec<u8>, TermConversionError>
pub fn try_into_string(self) -> Result<String, TermConversionError>
pub fn try_into_atom(self) -> Result<Arc<str>, TermConversionError>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn estimated_encoded_size(&self) -> usize
Sourcepub fn as_2_tuple(&self) -> Option<(&OwnedTerm, &OwnedTerm)>
pub fn as_2_tuple(&self) -> Option<(&OwnedTerm, &OwnedTerm)>
Returns the elements of a 2-tuple, or None if not a 2-tuple.
§Example
use erltf::OwnedTerm;
let term = OwnedTerm::Tuple(vec![OwnedTerm::atom("ok"), OwnedTerm::integer(42)]);
if let Some((first, second)) = term.as_2_tuple() {
assert!(first.is_atom_with_name("ok"));
assert_eq!(second.as_integer(), Some(42));
}Sourcepub fn as_3_tuple(&self) -> Option<(&OwnedTerm, &OwnedTerm, &OwnedTerm)>
pub fn as_3_tuple(&self) -> Option<(&OwnedTerm, &OwnedTerm, &OwnedTerm)>
Returns the elements of a 3-tuple, or None if not a 3-tuple.
Sourcepub fn as_4_tuple(
&self,
) -> Option<(&OwnedTerm, &OwnedTerm, &OwnedTerm, &OwnedTerm)>
pub fn as_4_tuple( &self, ) -> Option<(&OwnedTerm, &OwnedTerm, &OwnedTerm, &OwnedTerm)>
Returns the elements of a 4-tuple, or None if not a 4-tuple.
Sourcepub fn as_ok_tuple(&self) -> Option<&OwnedTerm>
pub fn as_ok_tuple(&self) -> Option<&OwnedTerm>
Returns the value from an {:ok, value} tuple, or None if not in that format.
§Example
use erltf::OwnedTerm;
let term = OwnedTerm::ok_tuple(OwnedTerm::integer(42));
assert_eq!(term.as_ok_tuple().and_then(|v| v.as_integer()), Some(42));Sourcepub fn as_error_tuple(&self) -> Option<&OwnedTerm>
pub fn as_error_tuple(&self) -> Option<&OwnedTerm>
Returns the reason from an {:error, reason} tuple, or None if not in that format.
Sourcepub fn as_ok_error(&self) -> Result<&OwnedTerm, &OwnedTerm>
pub fn as_ok_error(&self) -> Result<&OwnedTerm, &OwnedTerm>
Converts an {:ok, value} or {:error, reason} tuple to a Result.
§Example
use erltf::OwnedTerm;
let ok_term = OwnedTerm::ok_tuple(OwnedTerm::integer(42));
assert!(ok_term.as_ok_error().is_ok());
let err_term = OwnedTerm::error_tuple(OwnedTerm::atom("not_found"));
assert!(err_term.as_ok_error().is_err());Sourcepub fn is_elixir_nil(&self) -> bool
pub fn is_elixir_nil(&self) -> bool
Returns true if this is the Elixir nil atom.
Sourcepub fn is_erlang_undefined(&self) -> bool
pub fn is_erlang_undefined(&self) -> bool
Returns true if this is the Erlang undefined atom.
Sourcepub fn is_nil_like(&self) -> bool
pub fn is_nil_like(&self) -> bool
Returns true if this is either nil or undefined.
Sourcepub fn elixir_nil() -> OwnedTerm
pub fn elixir_nil() -> OwnedTerm
Creates the Elixir nil atom.
Sourcepub fn erlang_undefined() -> OwnedTerm
pub fn erlang_undefined() -> OwnedTerm
Creates the Erlang undefined atom.
Sourcepub fn is_atom_one_of(&self, names: &[&str]) -> bool
pub fn is_atom_one_of(&self, names: &[&str]) -> bool
Returns true if this is an atom matching one of the provided names.
§Example
use erltf::OwnedTerm;
let term = OwnedTerm::atom("ok");
assert!(term.is_atom_one_of(&["ok", "error", "noreply"]));
assert!(!term.is_atom_one_of(&["stop", "continue"]));Sourcepub fn is_elixir_struct(&self) -> bool
pub fn is_elixir_struct(&self) -> bool
Returns true if this term is an Elixir struct (a map with __struct__ key).
§Example
use erltf::OwnedTerm;
use std::collections::BTreeMap;
let mut map = BTreeMap::new();
map.insert(OwnedTerm::atom("__struct__"), OwnedTerm::atom("Elixir.MyApp.User"));
map.insert(OwnedTerm::atom("name"), OwnedTerm::string("Alice".to_string()));
let term = OwnedTerm::Map(map);
assert!(term.is_elixir_struct());
assert_eq!(term.elixir_struct_module(), Some("Elixir.MyApp.User"));Sourcepub fn elixir_struct_module(&self) -> Option<&str>
pub fn elixir_struct_module(&self) -> Option<&str>
Returns the module name if this is an Elixir struct.
Sourcepub fn is_elixir_exception(&self) -> bool
pub fn is_elixir_exception(&self) -> bool
Returns true if this is an Elixir exception (has both __struct__ and __exception__ keys).
Source§impl OwnedTerm
impl OwnedTerm
pub fn map_builder() -> MapBuilder
pub fn list_builder() -> ListBuilder
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OwnedTerm
Available on crate feature serde only.
impl<'de> Deserialize<'de> for OwnedTerm
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<OwnedTerm, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<OwnedTerm, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<K, V> FromIterator<(K, V)> for OwnedTerm
impl<K, V> FromIterator<(K, V)> for OwnedTerm
Source§impl<T> FromIterator<T> for OwnedTerm
impl<T> FromIterator<T> for OwnedTerm
Source§impl IntoIterator for OwnedTerm
impl IntoIterator for OwnedTerm
Source§impl KeyValueAccess for OwnedTerm
impl KeyValueAccess for OwnedTerm
Source§fn kv_get(&self, key: &str) -> Option<&OwnedTerm>
fn kv_get(&self, key: &str) -> Option<&OwnedTerm>
Source§fn kv_get_i64_or(&self, key: &str, default: i64) -> i64
fn kv_get_i64_or(&self, key: &str, default: i64) -> i64
Source§fn kv_get_bool_or(&self, key: &str, default: bool) -> bool
fn kv_get_bool_or(&self, key: &str, default: bool) -> bool
Source§fn kv_get_atom_string(&self, key: &str) -> Option<String>
fn kv_get_atom_string(&self, key: &str) -> Option<String>
Source§fn kv_get_atom_string_or(&self, key: &str, default: &str) -> String
fn kv_get_atom_string_or(&self, key: &str, default: &str) -> String
Source§fn kv_get_string_or(&self, key: &str, default: &str) -> String
fn kv_get_string_or(&self, key: &str, default: &str) -> String
Source§fn kv_get_pid(&self, key: &str) -> Option<&ExternalPid>
fn kv_get_pid(&self, key: &str) -> Option<&ExternalPid>
Source§fn kv_get_pid_string(&self, key: &str) -> Option<String>
fn kv_get_pid_string(&self, key: &str) -> Option<String>
Source§fn kv_get_pid_string_or(&self, key: &str, default: &str) -> String
fn kv_get_pid_string_or(&self, key: &str, default: &str) -> String
Source§impl Ord for OwnedTerm
impl Ord for OwnedTerm
Source§impl OwnedTermExt for OwnedTerm
impl OwnedTermExt for OwnedTerm
fn try_deserialize<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
fn try_deserialize_proplist<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Source§impl PartialOrd for OwnedTerm
impl PartialOrd for OwnedTerm
Source§impl Serialize for OwnedTerm
Available on crate feature serde only.
impl Serialize for OwnedTerm
serde only.