[][src]Module bcder::encode

Encoding data in BER.

This modules provides means to encode data in BER.

Encoding is done using helper types called encoders that represent the structure of the BER encoding. These types implement the trait Values. A type that can be encoded as BER typically provides a method named encode that produces a value of its encoder type representing the value’s encoding. If necessary, they can also provide a method encode_as that does the same thing but allows the caller to provide an tag to use for encoding as is necessary for implicit tagging.

The Values type can then be used to simply write the encoding to anything that implements the standard library’s io::Write trait.

The trait PrimitiveContent helps with producing encoders for types that use the primitive encoding. Through this trait the types can declare how their content is encoded and receive an automatic encoder type based on that.

The module also provides a number of helper types that make it easier to implement encoders in various situations.

For a more detailed introduction to writing the encode methods of types, see the encode section of the guide.

Structs

Constructed

A value encoder for a single constructed value.

Iter

A wrapper for an iterator of values.

Nothing

A encoder for nothing.

Primitive

A value encoder for primitively encoded types.

Slice

A wrapper for a slice of encodable values.

Enums

Choice2

A value encoder for a two-variant enum.

Choice3

A value encoder for a three-variant enum.

Traits

PrimitiveContent

A type that is encoded as a primitive value.

Values

A type that is a value encoder.

Functions

iter

Wraps an iterator over value encoders into a value encoder.

sequence

Returns a value encoder for a SEQUENCE containing inner.

sequence_as

Returns a value encoder for a SEQUENCE with the given tag.

set

Returns a value encoder for a SET containing inner.

set_as

Returns a value encoder for a SET with the given tag.

slice

Creates an encodable wrapper around a slice.

total_encoded_len

Returns the length for a structure based on the tag and content length.

write_header

Writes the header for a value.