#![forbid(unsafe_code)]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
mod cbor;
mod compress;
mod der;
mod detect;
mod dump;
mod edit;
mod encode_value;
mod error;
mod get;
mod json;
mod jsonpath;
mod jwt;
mod limits;
mod msgpack;
mod node;
mod path;
mod protobuf;
mod reencode;
mod text;
mod tree;
mod value;
pub mod varint;
pub use edit::{NewValue, Op, edit, parse_value, set};
pub use error::Diag;
pub use get::{JsonPick, Pick, get};
pub use node::{
Alphabet, Alt, AltKind, Asn1, Asn1Value, BYTES_HEAD, Codec, Detail, Field, FieldValue, Node,
TEXT_HEAD, TagClass,
};
pub use path::{JwtPick, is_der, is_jwt, is_values, select, select_der, select_jwt, select_value};
pub use text::{B64, decode_b64, decode_hex};
pub use value::{Value, ValueKind};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InputForm {
Auto,
Hex,
Base64,
Raw,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Force {
Protobuf,
Der,
Cbor,
Msgpack,
Text,
Bytes,
}
#[derive(Debug, Clone)]
pub struct Options {
pub depth: usize,
pub alts: usize,
pub input: InputForm,
pub force: Option<Force>,
pub max_items: usize,
}
pub const MAX_ITEMS: usize = 1_000_000;
impl Default for Options {
fn default() -> Self {
Self {
depth: 16,
alts: 3,
input: InputForm::Auto,
force: None,
max_items: MAX_ITEMS,
}
}
}
pub fn peel(input: &[u8], opts: &Options) -> Result<Node, Diag> {
detect::peel(input, opts)
}
pub fn innermost<'a>(root: &'a Node, input: &'a [u8]) -> &'a [u8] {
edit::innermost_buf(root, input)
}
pub fn to_json(node: &Node) -> String {
json::node_to_json(node)
}
pub fn field_to_json(field: &Field) -> String {
json::field_to_json(field)
}
pub fn diag_to_json(diag: &Diag) -> String {
json::diag_to_json(diag)
}
pub fn to_tree(node: &Node) -> String {
tree::node_to_tree(node)
}
pub fn value_to_json(v: &Value) -> String {
json::value_to_json(v)
}
pub fn value_to_tree(v: &Value) -> String {
tree::value_to_tree(v)
}
pub fn asn1_to_json(e: &Asn1) -> String {
json::asn1_to_json(e)
}
pub fn asn1_to_tree(e: &Asn1) -> String {
tree::asn1_to_tree(e)
}
pub fn field_to_tree(field: &Field) -> String {
tree::field_to_tree(field)
}