etcd-txn-parser

Crates.ioetcd-txn-parser
lib.rsetcd-txn-parser
version0.2.3
created_at2025-05-26 21:44:12.147988+00
updated_at2025-06-29 15:59:52.756134+00
descriptionAn etcd transaction parser
homepagehttps://github.com/Akanoa/etcd-txn-parser
repositoryhttps://github.com/Akanoa/etcd-txn-parser
max_upload_size
id1690293
size45,859
Akanoa (Akanoa)

documentation

https://docs.rs/etcd-txn-parser

README

Etcd transaction parser

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]+\""

Usage

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:#?}");
}
Commit count: 18

cargo fmt