Struct Builder

Source
pub struct Builder<S, T: MutableData> { /* private fields */ }
Expand description

Builder provides a low-level wire protocol builder object. This is generic over buffer types and uses type-state mutation to ensure created objects are valid

Implementations§

Source§

impl<S, T: MutableData> Builder<S, T>

Source

pub fn id(self, id: &Id) -> Self

Set the object id

Source

pub fn header_mut(&mut self) -> WireHeader<&mut [u8]>

Fetch a mutable instance of the object header

Source§

impl<T: MutableData> Builder<Init, T>

Source

pub fn new(buf: T) -> Self

Create a new base builder object

Source

pub fn header(self, header: &Header) -> Self

Set the object header. Note that length fields will be overwritten by actual lengths

Source

pub fn body<B: ImmutableData>( self, body: &NewBody<B>, secret_key: Option<&SecretKey>, ) -> Result<Builder<SetPrivateOptions, T>, Error>

Add body data, mutating the state of the builder

Source§

impl<T: MutableData> Builder<SetPrivateOptions, T>

Source

pub fn private_options<C: AsRef<[Options]>, E: ImmutableData>( self, options: &OptionsList<C, E>, secret_key: Option<&SecretKey>, ) -> Result<Builder<SetPublicOptions, T>, Error>

Encode private options This must be done in one pass as the entire options block is encrypted

Source§

impl<T: MutableData> Builder<SetPublicOptions, T>

Source

pub fn public_options<C: AsRef<[Options]>, E: ImmutableData>( self, options: &OptionsList<C, E>, ) -> Result<Builder<SetPublicOptions, T>, Error>

Encode a list of public options

Source

pub fn public_option(&mut self, option: &Options) -> Result<(), Error>

Add a single public option

Source

pub fn sign(self, signing_key: &PrivateKey) -> Result<Container<T>, Error>

Auto Trait Implementations§

§

impl<S, T> Freeze for Builder<S, T>
where T: Freeze,

§

impl<S, T> RefUnwindSafe for Builder<S, T>

§

impl<S, T> Send for Builder<S, T>
where T: Send, S: Send,

§

impl<S, T> Sync for Builder<S, T>
where T: Sync, S: Sync,

§

impl<S, T> Unpin for Builder<S, T>
where T: Unpin, S: Unpin,

§

impl<S, T> UnwindSafe for Builder<S, T>
where T: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.