Trait ockam_multiaddr::Codec

source ·
pub trait Codec: Send + Sync {
    // Required methods
    fn split_str<'a>(
        &self,
        prefix: &str,
        input: &'a str
    ) -> Result<(Checked<&'a str>, &'a str), Error>;
    fn split_bytes<'a>(
        &self,
        code: Code,
        input: &'a [u8]
    ) -> Result<(Checked<&'a [u8]>, &'a [u8]), Error>;
    fn is_valid_bytes(&self, code: Code, value: Checked<&[u8]>) -> bool;
    fn write_bytes(
        &self,
        val: &ProtoValue<'_>,
        buf: &mut dyn Buffer
    ) -> Result<(), Error>;
    fn transcode_str(
        &self,
        prefix: &str,
        value: Checked<&str>,
        buf: &mut dyn Buffer
    ) -> Result<(), Error>;
    fn transcode_bytes(
        &self,
        code: Code,
        value: Checked<&[u8]>,
        f: &mut Formatter<'_>
    ) -> Result<(), Error>;
}
Expand description

Type that understands how to read and write Protocols.

Required Methods§

source

fn split_str<'a>( &self, prefix: &str, input: &'a str ) -> Result<(Checked<&'a str>, &'a str), Error>

Split input string into the value and the remainder.

source

fn split_bytes<'a>( &self, code: Code, input: &'a [u8] ) -> Result<(Checked<&'a [u8]>, &'a [u8]), Error>

Split input bytes into the value and the remainder.

source

fn is_valid_bytes(&self, code: Code, value: Checked<&[u8]>) -> bool

Are the given input bytes valid w.r.t. the code?

source

fn write_bytes( &self, val: &ProtoValue<'_>, buf: &mut dyn Buffer ) -> Result<(), Error>

Write a protocol value to the given buffer.

source

fn transcode_str( &self, prefix: &str, value: Checked<&str>, buf: &mut dyn Buffer ) -> Result<(), Error>

Decode the string value and encode it into the buffer.

source

fn transcode_bytes( &self, code: Code, value: Checked<&[u8]>, f: &mut Formatter<'_> ) -> Result<(), Error>

Decode the bytes value and encode it into the formatter.

Implementors§