Skip to main content

Crate rnp_sexp

Crate rnp_sexp 

Source
Expand description

Pure-Rust S-expression parser and serializer for OpenPGP key formats.

A faithful port of librnp’s sexpp C++ library. Supports canonical, advanced, and base64 printing modes plus the GnuPG 2.3+ extended private key format.

use rnp_sexp::Sexp;

let input = "(8:test-key (1:a 3:bcd))";
let sexp = Sexp::parse_advanced(input).unwrap();
println!("{}", sexp.to_advanced());

Re-exports§

pub use error::Severity;
pub use error::SexpError;

Modules§

error
Error type and reporting infrastructure. Port of sexp-error.cpp.

Structs§

ExtKeyInputStream
Wraps the byte slice with continuation-line awareness required by the extended key format. The C++ implementation maintains an is_scanning_value flag that toggles continuation handling; this wrapper exposes it via Self::set_scanning_value.
ExtendedPrivateKey
SexpInputStream
SexpList
An S-expression list: (elem1 elem2 ...).
SexpOutputStream
SexpString
An S-expression string: raw bytes with an optional presentation hint.
SliceSource

Enums§

PrintMode
Sexp
An S-expression value: either a list or a string.

Traits§

CharSource
Source of bytes for the parser. The C++ implementation uses virtual dispatch (ext_key_input_stream_t::read_char overrides the base); we use a trait, with SliceSource as the default for raw byte slices.

Functions§

parse_advanced
parse_canonical
parse_extended
Convenience: parse input as an extended private key.