encoding::pem
The PEM module implements RFC 7468, commonly known as the PEM format, which is widely used for cryptographic data formats.
Index
Types
type b64stream = struct {
stream: io::stream,
in: bufio::scanner,
};
type decoder = struct {
in: b64stream,
label: memio::stream,
};
type pemdecoder = struct {
stream: io::stream,
b64: base64::decoder,
};
type pemencoder = struct {
stream: io::stream,
out: io::handle,
b64: base64::encoder,
label: str,
buf: [48]u8,
ln: u8,
};
Functions
fn finish(dec: *decoder) void;
fn newdecoder(in: io::handle) decoder;
fn newencoder(label: str, s: io::handle) (pemencoder | io::error);
fn next(dec: *decoder) ((str, pemdecoder) | io::EOF | io::error);
fn strerror(err: io::error) const str;
Types
type b64stream
Show undocumented member
type b64stream = struct {
stream: io::stream,
in: bufio::scanner,
};
type decoder
Show undocumented member
type decoder = struct {
in: b64stream,
label: memio::stream,
};
type pemdecoder
Show undocumented member
type pemdecoder = struct {
stream: io::stream,
b64: base64::decoder,
};
type pemencoder
Show undocumented member
type pemencoder = struct {
stream: io::stream,
out: io::handle,
b64: base64::encoder,
label: str,
buf: [48]u8,
ln: u8,
};
Functions
fn finish
fn finish(dec: *decoder) void;
Frees state associated with this decoder.
fn newdecoder
fn newdecoder(in: io::handle) decoder;
Creates a new PEM decoder. The caller must either read it until it returns io::EOF, or call finish to free state associated with the parser.
fn newencoder
fn newencoder(label: str, s: io::handle) (pemencoder | io::error);
Creates a new PEM encoder stream. The stream has to be closed to write the trailer.
fn next
fn next(dec: *decoder) ((str, pemdecoder) | io::EOF | io::error);
Finds the next PEM boundary in the stream, ignoring any non-PEM data, and returns the label and a pemdecoder from which the encoded data may be read, or io::EOF if no further PEM boundaries are found. The user must completely read the pemdecoder until it returns io::EOF before calling next again.
The label returned by this function is borrowed from the decoder state and does not contain "-----BEGIN " or "-----".
fn strerror
fn strerror(err: io::error) const str;
Converts an I/O error returned from a PEM decoder into a human-friendly string.