edn-rs
Near Stable
- This lib does not make effort to conform the EDN received to EDN Spec. The lib that generated this EDN should be responsible for this. For more information on Edn Spec please visit: https://github.com/edn-format/edn.
Current example usage in:
Usage
Cargo.toml
[]
= "0.11.1"
Parse an EDN token into a Edn with edn! macro:
use ;
Parse an EDN String with from_str:
use ;
use FromStr;
To navigate through Edn data you can just use get and get_mut:
use ;
Serializes Rust Types into EDN with ser_struct!
use ;
use ;
Emits EDN format from a Json
use json_to_edn;
Using async/await with Edn type
Edn supports futures by using the feature async. To enable this feature add to your Cargo.toml dependencies the following line edn-rs = { version = 0.11.1", features = ["async"] } and you can use futures as in the following example.
use ;
use *;
use Future;
use *;
async + Send
async
Edn-rs Current Features
- Define
structto map EDN infoEdnNode - Define EDN types,
EdnType - Edn Type into primitive:
Edn::Bool(true).into() -> true. This was done byto_float,to_bool,to_int,to_vec. - implement
futures::Futuretrait toEdn - Parse EDN data
parse_edn:- nil
"" - String
"\"string\"" - Numbers
"324352","3442.234","3/4" - Keywords
:a - Symbol
sym-bol-s - Vector
"[1 :2 \"d\"]" - List
"(1 :2 \"d\")" - Set
"#{1 2 3}" - Map
"{:a 1 :b 2 }" - Nested structures
"{:a \"2\" :b [true false] :c #{:A {:a :b} nil}}"
- nil
- Simple data structures in one another
edn!:- Vec in Vec
"[1 2 [:3 \"4\"]]" - Set in Vec
"[1 2 #{:3 \"4\"}]" - List in List
"(1 2 (:3 \"4\"))" - List in Set
"'#{1 2 (:3 \"4\")}" - Maps in general
"{:a 2 :b {:3 \"4\"}}","{:a 2 :b [:3 \"4\"]}"
- Vec in Vec
- Multiple simple data structures in one another (Map and Set in a vector)
- Multi deepen data structures (Map in a Set in a List in a Vec in a Vec)
- Navigate through Edn Data
- Navigate through Sets. DOne by
set_iter
- Navigate through Sets. DOne by
- Json to Edn
- Json String to EDN String
- macro to process Structs and Enums to EDN
- trait Deserialize EDN to Struct
- trait Serialize struct to EDN
edn-derive
edn-derive is a proc-macro crate to (De)serialize Edn values, currently it is pre-alpha and it can be found at crates.io or at github.
Usage
Just add to your Cargo.toml the following:
[]
= "<version>"
= 0.11.1"
Examples
Serialize
use Serialize as SerializeEdn;
use Serialize;
Current Features
-
derive Serialize -
to_stringorto_edn -
derive Deserialize -
let val: YourStruct = edn_rs::from_str(&str)