encoding::pem+x86_64 +linux

The PEM module implements RFC 7468, commonly known as the PEM format, which is widely used for cryptographic data formats.

Index

Types

// Undocumented types:
type b64stream = struct {
	stream: io::stream,
	in: bufio::stream,
};
type decoder = struct {
	in: b64stream,
	label: memio::stream,
	buf: []u8,
};
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[link]

Show undocumented member
type b64stream = struct {
	stream: io::stream,
	in: bufio::stream,
};

type decoder[link]

Show undocumented member
type decoder = struct {
	in: b64stream,
	label: memio::stream,
	buf: []u8,
};

type pemdecoder[link]

Show undocumented member
type pemdecoder = struct {
	stream: io::stream,
	b64: base64::decoder,
};

type pemencoder[link]

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[link]

fn finish(dec: *decoder) void;

Frees state associated with this decoder.

fn newdecoder[link]

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[link]

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[link]

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[link]

fn strerror(err: io::error) const str;

Converts an I/O error returned from a PEM decoder into a human-friendly string.