Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

ToExtension

Trait ToExtension 

Source
pub trait ToExtension {
    type Error;

    // Required method
    fn to_extension(
        self,
        subject: &Name,
        extensions: &[Extension],
    ) -> Result<Extension, Self::Error>;
}
Expand description

Trait to be implemented by extensions to allow them to be formatted as x509 v3 extensions by builder.

§Examples

use const_oid::{AssociatedOid, ObjectIdentifier};
use x509_cert::{der::Sequence, ext, name};

/// This extension indicates the age of the captain at the time of signature
#[derive(Clone, Debug, Eq, PartialEq, Sequence)]
pub struct CaptainAge {
    pub age: u32,
}

impl AssociatedOid for CaptainAge {
    const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.6.1.4.1.32473.1");
}

impl ext::Criticality for CaptainAge {
    fn criticality(&self, _subject: &name::Name, _extensions: &[ext::Extension]) -> bool {
        false
    }
}

Required Associated Types§

Source

type Error

The error type returned when encoding the extension.

Required Methods§

Source

fn to_extension( self, subject: &Name, extensions: &[Extension], ) -> Result<Extension, Self::Error>

Returns the Extension with the content encoded.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> ToExtension for &T

Source§

type Error = Error

Source§

fn to_extension( self, subject: &Name, extensions: &[Extension], ) -> Result<Extension, <&T as ToExtension>::Error>

Source§

impl<T> ToExtension for (ObjectIdentifier, &T)
where T: Criticality + Encode,

Source§

type Error = Error

Source§

fn to_extension( self, subject: &Name, extensions: &[Extension], ) -> Result<Extension, <(ObjectIdentifier, &T) as ToExtension>::Error>

Source§

impl<T> ToExtension for (ObjectIdentifier, bool, &T)
where T: Encode,

Source§

type Error = Error

Source§

fn to_extension( self, _subject: &Name, _extensions: &[Extension], ) -> Result<Extension, <(ObjectIdentifier, bool, &T) as ToExtension>::Error>

Source§

impl<T> ToExtension for (bool, &T)
where T: AssociatedOid + Encode,

Source§

type Error = Error

Source§

fn to_extension( self, subject: &Name, extensions: &[Extension], ) -> Result<Extension, <(bool, &T) as ToExtension>::Error>

Implementors§