[−][src]Trait bcder::encode::PrimitiveContent
A type that is encoded as a primitive value.
This trait should be implemented for types that use primitive encoding.
It defines, how the content octets of a single primitive value containing
a value of the type are to be created. As a consequence, these types
gain the encode
and encode_as
methods from their implementation
of this trait.
Note that the trait requires implementing types to be Copy
to
avoid unnecessary lifetime parameters on the encoder type. For types that
aren’t Copy
, PrimitiveContent
should be implemented on a reference to
the type instead.
Associated Constants
Loading content...Required methods
pub fn encoded_len(&self, mode: Mode) -> usize
[src]
Returns the length of the encoded content of this type.
pub fn write_encoded<W: Write>(
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
Writes the encoded content to a writer.
Provided methods
pub fn to_encoded_bytes(&self, mode: Mode) -> Bytes
[src]
Encodes the value to bytes (useful when you need to sign a structure)
pub fn encode(self) -> Primitive<Self>
[src]
Returns a value encoder for this content using the natural tag.
This is identical to self.encode_as(Self::TAG)
pub fn encode_as(self, tag: Tag) -> Primitive<Self>
[src]
Returns a value encoder for this content using the given tag.
The returned value is a content encoder that produces a single
primitive BER encoded value. The tag for this value is explicitely
given via the tag
argument.
pub fn encode_ref(&self) -> Primitive<&Self>
[src]
Returns a value encoder for a reference using the natural tag.
pub fn encode_ref_as(&self, tag: Tag) -> Primitive<&Self>
[src]
Returns a value encoder for a reference using the given tag.
Implementations on Foreign Types
impl<'a, T: PrimitiveContent> PrimitiveContent for &'a T
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, mode: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for u8
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for u16
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for u32
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for u64
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for u128
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for i8
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for i16
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for i32
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for i64
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for i128
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl PrimitiveContent for ()
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(&self, _: Mode, _: &mut W) -> Result<(), Error>
[src]
impl PrimitiveContent for bool
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl<'a> PrimitiveContent for &'a [u8]
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
Implementors
impl PrimitiveContent for BitString
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_: Mode,
target: &mut W
) -> Result<(), Error>
impl<'a> PrimitiveContent for &'a Integer
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, _mode: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
_mode: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
_mode: Mode,
target: &mut W
) -> Result<(), Error>
impl<'a> PrimitiveContent for &'a Unsigned
[src]
pub const TAG: Tag
[src]
pub fn encoded_len(&self, mode: Mode) -> usize
[src]
pub fn write_encoded<W: Write>(
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>