Trait ockam_multiaddr::Protocol
source · [−]pub trait Protocol<'a>: Sized {
const CODE: Code;
const PREFIX: &'static str;
fn read_str(input: Checked<&'a str>) -> Result<Self, Error>;
fn write_str(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
fn read_bytes(input: Checked<&'a [u8]>) -> Result<Self, Error>;
fn write_bytes(&self, buf: &mut dyn Buffer);
}
Expand description
Component of a MultiAddr
.
A protocol supports a textual and a binary representation.
Protocol <- Text / Binary
Text <- '/' Prefix '/' Char+
Prefix <- Char+
Binary <- Code Byte+
Code <- UnsignedVarint
To process a protocol, one needs to know the code and prefix as they determine the protocol value.
NB: Protocol values which contain ’/’s create ambiguity in the textual representation. These so called “path protocols” must be the last protocol component in a multi-address.
Required Associated Constants
Required Methods
Parse the string value of this protocol.
Write the protocol as a string, including the prefix.
Decode the binary value of this protocol.
sourcefn write_bytes(&self, buf: &mut dyn Buffer)
fn write_bytes(&self, buf: &mut dyn Buffer)
Write the protocol as a binary value, including the code.