| Crates.io | etcd-txn-parser |
| lib.rs | etcd-txn-parser |
| version | 0.2.3 |
| created_at | 2025-05-26 21:44:12.147988+00 |
| updated_at | 2025-06-29 15:59:52.756134+00 |
| description | An etcd transaction parser |
| homepage | https://github.com/Akanoa/etcd-txn-parser |
| repository | https://github.com/Akanoa/etcd-txn-parser |
| max_upload_size | |
| id | 1690293 |
| size | 45,859 |
Uses the noa-parser library to parse etcd transaction files.
<Txn> ::= <CMP>* "\n" <THEN> "\n" <ELSE> "\n"
<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>|<CMPLEASE>) "\n"
<CMPOP> ::= "<" | "=" | ">"
<CMPCREATE> := ("c"|"create")"("<KEY>")" <CMPOP> <REVISION>
<CMPMOD> ::= ("m"|"mod")"("<KEY>")" <CMPOP> <REVISION>
<CMPVAL> ::= ("val"|"value")"("<KEY>")" <CMPOP> <VALUE>
<CMPVER> ::= ("ver"|"version")"("<KEY>")" <CMPOP> <VERSION>
<CMPLEASE> ::= "lease("<KEY>")" <CMPOP> <LEASE>
<THEN> ::= <OP>*
<ELSE> ::= <OP>*
<OP> ::= ((see put, get, del etcdctl command syntax)) "\n"
<KEY> ::= (%q formatted string)
<VALUE> ::= (%q formatted string)
<REVISION> ::= "\""[0-9]+"\""
<VERSION> ::= "\""[0-9]+"\""
<LEASE> ::= "\""[0-9]+\""
use etcd_txn_parser::parse;
fn main() {
let txn = r#"mod("key1") > 0
put key1 "overwrote-key1"
put "key1" "created-key1"
put key2 "some extra key""#;
let txn = parse(txn.as_bytes());
println!("{txn:#?}");
}