pub trait Ticket: Sized {
const KIND: &'static str;
// Required methods
fn to_bytes(&self) -> Vec<u8>;
fn from_bytes(bytes: &[u8]) -> Result<Self, Error>;
// Provided methods
fn serialize(&self) -> String { ... }
fn deserialize(str: &str) -> Result<Self, Error> { ... }
}
base32
only.Expand description
A ticket is a serializable object combining information required for an operation.
Typically tickets contain all information required for an operation, e.g. an iroh blob ticket would contain the hash of the data as well as information about how to reach the provider.
Tickets support serialization to a string using base32 encoding. The kind of ticket will be prepended to the string to make it somewhat self describing.
Versioning is left to the implementer. Some kinds of tickets might need versioning, others might not.
The serialization format for converting the ticket from and to bytes is left to the implementer. We recommend using postcard for serialization.
Required Associated Constants§
Required Methods§
Sourcefn from_bytes(bytes: &[u8]) -> Result<Self, Error>
fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Deserialize from the base32 string representation bytes.
Provided Methods§
Sourcefn deserialize(str: &str) -> Result<Self, Error>
fn deserialize(str: &str) -> Result<Self, Error>
Deserialize from a string.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.