#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
)]
#![deny(unsafe_code)]
#![warn(
clippy::arithmetic_side_effects,
clippy::mod_module_files,
clippy::panic,
clippy::panic_in_result_fn,
clippy::unwrap_used,
missing_docs,
rust_2018_idioms,
unused_lifetimes,
unused_qualifications
)]
#![cfg_attr(feature = "std", doc = " ```")]
#![cfg_attr(not(feature = "std"), doc = " ```ignore")]
#[cfg(feature = "alloc")]
#[macro_use]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
mod decoder;
mod encoder;
mod error;
mod grammar;
pub use crate::{
decoder::{Decoder, decode, decode_label, detect_base64_line_width},
encoder::{Encoder, encapsulated_len, encapsulated_len_wrapped, encode, encoded_len},
error::{Error, Result},
};
pub use base64ct::LineEnding;
#[cfg(feature = "alloc")]
pub use crate::{decoder::decode_vec, encoder::encode_string};
const PRE_ENCAPSULATION_BOUNDARY: &[u8] = b"-----BEGIN ";
const POST_ENCAPSULATION_BOUNDARY: &[u8] = b"-----END ";
const ENCAPSULATION_BOUNDARY_DELIMITER: &[u8] = b"-----";
pub const BASE64_WRAP_WIDTH: usize = 64;
pub type Base64Decoder<'i> = base64ct::Decoder<'i, base64ct::Base64>;
pub type Base64Encoder<'o> = base64ct::Encoder<'o, base64ct::Base64>;
pub trait PemLabel {
const PEM_LABEL: &'static str;
fn validate_pem_label(actual: &str) -> Result<()> {
if Self::PEM_LABEL == actual {
Ok(())
} else {
Err(Error::UnexpectedTypeLabel {
expected: Self::PEM_LABEL,
})
}
}
}