pub trait Codec: Debug + Sized {
    // Required methods
    fn encode(&self, bytes: &mut Vec<u8>);
    fn read(_: &mut Reader<'_>) -> Option<Self>;

    // Provided methods
    fn get_encoding(&self) -> Vec<u8>  { ... }
    fn read_bytes(bytes: &[u8]) -> Option<Self> { ... }
}
Expand description

Trait for implementing encoding and decoding functionality on something.

Required Methods§

fn encode(&self, bytes: &mut Vec<u8>)

Function for encoding itself by appending itself to the provided vec of bytes.

fn read(_: &mut Reader<'_>) -> Option<Self>

Function for decoding itself from the provided reader will return Some if the decoding was successful or None if it was not.

Provided Methods§

fn get_encoding(&self) -> Vec<u8>

Convenience function for encoding the implementation into a vec and returning it

fn read_bytes(bytes: &[u8]) -> Option<Self>

Function for wrapping a call to the read function in a Reader for the slice of bytes provided

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl Codec for u8

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<u8>

§

impl Codec for u16

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<u16>

§

impl Codec for u32

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<u32>

§

impl Codec for u64

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<u64>

§

impl Codec for Vec<NamedGroup>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<NamedGroup>>

§

impl Codec for Vec<ProtocolVersion>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<ProtocolVersion>>

§

impl Codec for Vec<SignatureScheme>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<SignatureScheme>>

§

impl Codec for Vec<ClientCertificateType>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<ClientCertificateType>>

§

impl Codec for Vec<ECPointFormat>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<ECPointFormat>>

§

impl Codec for Vec<PSKKeyExchangeMode>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<PSKKeyExchangeMode>>

§

impl Codec for Vec<CertReqExtension>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<CertReqExtension>>

§

impl Codec for Vec<CertificateExtension>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<CertificateExtension>>

§

impl Codec for Vec<NewSessionTicketExtension>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<NewSessionTicketExtension>>

§

impl Codec for Vec<ServerExtension>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<ServerExtension>>

§

impl Codec for Vec<PayloadU8>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<PayloadU8>>

§

impl Codec for Vec<PayloadU16>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<PayloadU16>>

§

impl Codec for Vec<KeyShareEntry>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<KeyShareEntry>>

§

impl Codec for Vec<PresharedKeyIdentity>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<PresharedKeyIdentity>>

§

impl Codec for Vec<ServerName>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<ServerName>>

§

impl Codec for Vec<Certificate>

§

fn encode(&self, bytes: &mut Vec<u8>)

§

fn read(r: &mut Reader<'_>) -> Option<Vec<Certificate>>

Implementors§

§

impl Codec for AlertDescription

§

impl Codec for CipherSuite

§

impl Codec for ContentType

§

impl Codec for HandshakeType

§

impl Codec for NamedGroup

§

impl Codec for ProtocolVersion

§

impl Codec for SignatureAlgorithm

§

impl Codec for SignatureScheme

§

impl Codec for AlertLevel

§

impl Codec for CertificateStatusType

§

impl Codec for ClientCertificateType

§

impl Codec for Compression

§

impl Codec for ECCurveType

§

impl Codec for ECPointFormat

§

impl Codec for ExtensionType

§

impl Codec for HashAlgorithm

§

impl Codec for HeartbeatMessageType

§

impl Codec for HeartbeatMode

§

impl Codec for KeyUpdateRequest

§

impl Codec for NamedCurve

§

impl Codec for PSKKeyExchangeMode

§

impl Codec for ServerNameType

§

impl Codec for CertReqExtension

§

impl Codec for CertificateExtension

§

impl Codec for CertificateStatusRequest

§

impl Codec for ClientExtension

§

impl Codec for HelloRetryExtension

§

impl Codec for NewSessionTicketExtension

§

impl Codec for ServerExtension

§

impl Codec for ServerKeyExchangePayload

§

impl Codec for AlertMessagePayload

§

impl Codec for Payload

§

impl Codec for PayloadU8

§

impl Codec for PayloadU16

§

impl Codec for PayloadU24

§

impl Codec for ChangeCipherSpecPayload

§

impl Codec for u24

§

impl Codec for CertificateEntry

§

impl Codec for CertificatePayloadTLS13

§

impl Codec for CertificateRequestPayload

§

impl Codec for CertificateRequestPayloadTLS13

§

impl Codec for CertificateStatus

§

impl Codec for ClientECDHParams

§

impl Codec for ClientHelloPayload

§

impl Codec for ECDHEServerKeyExchange

§

impl Codec for ECParameters

§

impl Codec for HandshakeMessagePayload

§

impl Codec for HelloRetryRequest

§

impl Codec for KeyShareEntry

§

impl Codec for NewSessionTicketPayload

§

impl Codec for NewSessionTicketPayloadTLS13

§

impl Codec for OCSPCertificateStatusRequest

§

impl Codec for PresharedKeyIdentity

§

impl Codec for PresharedKeyOffer

§

impl Codec for Random

§

impl Codec for ServerECDHParams

§

impl Codec for ServerHelloPayload

§

impl Codec for ServerName

§

impl Codec for SessionID

§

impl Codec for ClientSessionKey

§

impl Codec for ServerSessionValue

§

impl Codec for Certificate

§

impl Codec for DigitallySignedStruct