Enum cirru_edn::Edn

source ·
pub enum Edn {
Show 14 variants Nil, Bool(bool), Number(f64), Symbol(Arc<str>), Tag(EdnTag), Str(Arc<str>), Quote(Cirru), Tuple(EdnTupleView), List(EdnListView), Set(EdnSetView), Map(EdnMapView), Record(EdnRecordView), Buffer(Vec<u8>), AnyRef(EdnAnyRef),
}
Expand description

Data format based on subset of EDN, but in Cirru syntax. different parts are quote and Record.

Variants§

§

Nil

§

Bool(bool)

§

Number(f64)

§

Symbol(Arc<str>)

§

Tag(EdnTag)

§

Str(Arc<str>)

§

Quote(Cirru)

§

Tuple(EdnTupleView)

§

List(EdnListView)

§

Set(EdnSetView)

§

Map(EdnMapView)

§

Record(EdnRecordView)

§

Buffer(Vec<u8>)

§

AnyRef(EdnAnyRef)

reference to Rust data, not interpretable in Calcit

Implementations§

source§

impl Edn

Support reading from EDN

source

pub fn str<T: Into<Arc<str>>>(s: T) -> Self

create new string

source

pub fn tag<T: Into<Arc<str>>>(s: T) -> Self

create new tag

source

pub fn sym<T: Into<Arc<str>>>(s: T) -> Self

create new symbol

source

pub fn tuple(tag: Self, extra: Vec<Self>) -> Self

create new tuple

source

pub fn any_ref<T: ToOwned + Any>(d: T) -> Self

create any-ref

source

pub fn is_literal(&self) -> bool

source

pub fn map_from_iter<T: IntoIterator<Item = (Edn, Edn)>>(pairs: T) -> Self

source

pub fn record_from_pairs(tag: EdnTag, pairs: &[(EdnTag, Edn)]) -> Self

source

pub fn read_string(&self) -> Result<String, String>

source

pub fn read_symbol_string(&self) -> Result<String, String>

source

pub fn read_str(&self) -> Result<Arc<str>, String>

source

pub fn read_symbol_str(&self) -> Result<Arc<str>, String>

source

pub fn read_tag_str(&self) -> Result<Arc<str>, String>

source

pub fn read_bool(&self) -> Result<bool, String>

source

pub fn read_number(&self) -> Result<f64, String>

source

pub fn read_quoted_cirru(&self) -> Result<Cirru, String>

source

pub fn view_list(&self) -> Result<EdnListView, String>

get List variant in struct

source

pub fn view_map(&self) -> Result<EdnMapView, String>

get Map variant in struct

source

pub fn view_set(&self) -> Result<EdnSetView, String>

get Set variant in struct

source

pub fn view_record(&self) -> Result<EdnRecordView, String>

get Record variant in struct

source

pub fn view_tuple(&self) -> Result<EdnTupleView, String>

get Tuple variant in struct

Trait Implementations§

source§

impl Clone for Edn

source§

fn clone(&self) -> Edn

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Edn

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Edn

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T> From<&'a [&'a T]> for Edn
where T: Into<Edn> + Clone,

source§

fn from(xs: &'a [&'a T]) -> Self

Converts to this type from the input type.
source§

impl From<&[Edn]> for Edn

source§

fn from(xs: &[Edn]) -> Self

Converts to this type from the input type.
source§

impl From<&Arc<str>> for Edn

source§

fn from(x: &Arc<str>) -> Self

Converts to this type from the input type.
source§

impl From<&Box<str>> for Edn

source§

fn from(x: &Box<str>) -> Self

Converts to this type from the input type.
source§

impl From<&Cirru> for Edn

source§

fn from(x: &Cirru) -> Self

Converts to this type from the input type.
source§

impl From<&EdnTag> for Edn

source§

fn from(k: &EdnTag) -> Edn

Converts to this type from the input type.
source§

impl<'a, T, K> From<&'a HashMap<&'a K, &'a T>> for Edn
where T: Into<Edn> + Clone, K: Into<Edn> + Clone,

source§

fn from(xs: &'a HashMap<&'a K, &'a T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a HashSet<&'a T>> for Edn
where T: Into<Edn> + Clone,

source§

fn from(xs: &'a HashSet<&'a T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a Option<&'a T>> for Edn
where T: Into<Edn> + Clone,

source§

fn from(xs: &'a Option<&'a T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a Vec<&'a T>> for Edn
where T: Into<Edn> + Clone,

source§

fn from(xs: &'a Vec<&'a T>) -> Self

Converts to this type from the input type.
source§

impl From<&bool> for Edn

source§

fn from(x: &bool) -> Self

Converts to this type from the input type.
source§

impl From<&f32> for Edn

source§

fn from(x: &f32) -> Self

Converts to this type from the input type.
source§

impl From<&f64> for Edn

source§

fn from(x: &f64) -> Self

Converts to this type from the input type.
source§

impl From<&i64> for Edn

source§

fn from(x: &i64) -> Self

Converts to this type from the input type.
source§

impl From<&i8> for Edn

source§

fn from(x: &i8) -> Self

Converts to this type from the input type.
source§

impl From<&str> for Edn

source§

fn from(x: &str) -> Self

Converts to this type from the input type.
source§

impl From<&u8> for Edn

source§

fn from(x: &u8) -> Self

Converts to this type from the input type.
source§

impl From<(Arc<Edn>, Vec<Edn>)> for Edn

source§

fn from((tag, extra): (Arc<Edn>, Vec<Edn>)) -> Edn

Converts to this type from the input type.
source§

impl From<Arc<str>> for Edn

source§

fn from(x: Arc<str>) -> Self

Converts to this type from the input type.
source§

impl From<Box<str>> for Edn

source§

fn from(x: Box<str>) -> Self

Converts to this type from the input type.
source§

impl From<Cirru> for Edn

source§

fn from(x: Cirru) -> Self

Converts to this type from the input type.
source§

impl From<EdnListView> for Edn

source§

fn from(x: EdnListView) -> Edn

Converts to this type from the input type.
source§

impl From<EdnMapView> for Edn

source§

fn from(x: EdnMapView) -> Edn

Converts to this type from the input type.
source§

impl From<EdnRecordView> for Edn

source§

fn from(x: EdnRecordView) -> Edn

Converts to this type from the input type.
source§

impl From<EdnSetView> for Edn

source§

fn from(x: EdnSetView) -> Edn

Converts to this type from the input type.
source§

impl From<EdnTag> for Edn

source§

fn from(k: EdnTag) -> Edn

Converts to this type from the input type.
source§

impl From<EdnTupleView> for Edn

source§

fn from(x: EdnTupleView) -> Edn

Converts to this type from the input type.
source§

impl<T, K> From<HashMap<K, T>> for Edn
where T: Into<Edn>, K: Into<Edn>,

source§

fn from(xs: HashMap<K, T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<HashSet<T>> for Edn
where T: Into<Edn>,

source§

fn from(xs: HashSet<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Option<T>> for Edn
where T: Into<Edn>,

Option<T> is a special case to convert since it has it’s own implementation in core. To handle Edn::Nil which is dynamically typed, some code like this is required:

{
  let v = value.map_get("<FIELD_NAME>")?;
  if v == Edn::Nil {
    None
  } else {
    Some(v.try_into()?)
  }
}
source§

fn from(xs: Option<T>) -> Self

Converts to this type from the input type.
source§

impl From<String> for Edn

source§

fn from(x: String) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for Edn
where T: Into<Edn>,

source§

fn from(xs: Vec<T>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Edn

source§

fn from(x: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Edn

source§

fn from(x: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Edn

source§

fn from(x: f64) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Edn

source§

fn from(x: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for Edn

source§

fn from(x: i8) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Edn

source§

fn from(x: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for Edn

source§

fn from(x: usize) -> Self

Converts to this type from the input type.
source§

impl Hash for Edn

source§

fn hash<H>(&self, _state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Edn

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Edn

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Edn

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<&Edn> for String

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: &Edn) -> Result<String, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for Arc<str>

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for Cirru

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for EdnListView

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(value: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for EdnMapView

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(data: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for EdnRecordView

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(data: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for EdnSetView

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(data: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for EdnTag

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<EdnTag, String>

Performs the conversion.
source§

impl TryFrom<Edn> for EdnTupleView

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(data: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, K> TryFrom<Edn> for HashMap<K, T>
where T: TryFrom<Edn, Error = String>, K: TryFrom<Edn, Error = String> + Eq + Hash,

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T> TryFrom<Edn> for HashSet<T>
where T: TryFrom<Edn, Error = String> + Eq + Hash,

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for String

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<String, Self::Error>

Performs the conversion.
source§

impl<T> TryFrom<Edn> for Vec<T>
where T: TryFrom<Edn, Error = String>,

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for bool

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for f32

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for f64

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for i64

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for i8

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Edn> for u8

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(x: Edn) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Edn

Auto Trait Implementations§

§

impl Freeze for Edn

§

impl RefUnwindSafe for Edn

§

impl Send for Edn

§

impl Sync for Edn

§

impl Unpin for Edn

§

impl UnwindSafe for Edn

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.