Struct domain::rdata::svcb::SvcParamsBuilder

source ·
pub struct SvcParamsBuilder<Octs> { /* private fields */ }
Expand description

A builder for a service parameter sequence.

This type wraps an octets builder and allows appending parameter values. You can create a new empty builder using the empty function or copy an existing value through from_params.

You can add additional values using the push method. There are also dedicated methods for all known value types. The builder will make sure that each parameter key can only appear once. Thus, pushing values may fail if a value is already present.

The builder also takes care of sorting the values into their correct order. So you can push them in any order.

It only sorts the items when producing a frozen value via the freeze method.

Implementations§

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn mandatory( &mut self, keys: impl AsRef<[SvcParamKey]>, ) -> Result<(), PushValueError>

Adds a ‘mandatory’ value with the given keys.

Returns an error if there already is a ‘mandatory’ value, keys contains more values than fit into a service binding parameter value, or the underlying octets builder runs out of space.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn alpn(&mut self, protocols: &[&[u8]]) -> Result<(), PushAlpnError>

Adds an ALPN value to the parameters.

The ALPN protocol names to be included in the value must be provided as a slice of those names in order to be able to calculate the length of the value up front.

Returns an error if there already is an ALPN value, or if protocols contains more values than fit into a service binding parameter value, or the underlying octets builder runs out of space.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn no_default_alpn(&mut self) -> Result<(), PushError>

Adds the NoDefaultAlpn value.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn port(&mut self, port: u16) -> Result<(), PushError>

Adds a port value with the given port number.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn ech<Source: AsRef<[u8]> + ?Sized>( &mut self, ech: &Source, ) -> Result<(), PushValueError>

Adds a port value with the given port number.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn ipv4hint( &mut self, addrs: impl AsRef<[Ipv4Addr]>, ) -> Result<(), PushValueError>

Adds an ‘ipv4hint’ value with the given addresses.

Returns an error if there already is an ‘ipv4hint’ value, addrs contains more values than fit into a service binding parameter value, or the underlying octets builder runs out of space.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn ipv6hint( &mut self, addrs: impl AsRef<[Ipv6Addr]>, ) -> Result<(), PushValueError>

Adds an ‘ipv6hint’ value with the given addresses.

Returns an error if there already is an ‘ipv6hint’ value, addrs contains more values than fit into a service binding parameter value, or the underlying octets builder runs out of space.

source§

impl<Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> SvcParamsBuilder<Octs>

source

pub fn dohpath(&mut self, template: &str) -> Result<(), PushValueError>

Adds a ‘dohpath’ value with the URI template.

Returns an error if there already is a ‘dohpath’ value, template is too long to fit in a service binding parameter value, or the underlying octets builder runs out of space.

source§

impl<Octs> SvcParamsBuilder<Octs>

source

pub fn empty() -> Self
where Octs: EmptyBuilder,

Creates an empty parameter builder.

source

pub fn from_params<Src: Octets + ?Sized>( params: &SvcParams<Src>, ) -> Result<Self, ShortBuf>
where Octs: AsRef<[u8]> + OctetsBuilder + EmptyBuilder,

Creates a parameter builder from an existing parameter sequence.

The function creates a new empty builder and copies over the content of params. It can fail if the octets builder is not capable of providing enough space to hold the content of params.

source

pub fn push<Value: ComposeSvcParamValue + ?Sized>( &mut self, value: &Value, ) -> Result<(), PushError>
where Octs: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>,

Adds a new value to the builder.

The method will return an error if a value with this key is already present or if there isn’t enough space left in the builder’s buffer.

source

pub fn freeze<Target>( &self, ) -> Result<SvcParams<Target>, <<Target as FromBuilder>::Builder as OctetsBuilder>::AppendError>
where Octs: AsRef<[u8]>, Target: FromBuilder, <Target as FromBuilder>::Builder: OctetsBuilder + EmptyBuilder,

Freezes the builder to a parameter sequence.

Because the values may need to be resorted, this method actually produces a new octets sequence. This is why it doesn’t consume the builder and may fail if the target octet’s builder can’t provide enough space.

Trait Implementations§

source§

impl<Octs: Clone> Clone for SvcParamsBuilder<Octs>

source§

fn clone(&self) -> SvcParamsBuilder<Octs>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Octs: Debug> Debug for SvcParamsBuilder<Octs>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Octs> Freeze for SvcParamsBuilder<Octs>
where Octs: Freeze,

§

impl<Octs> RefUnwindSafe for SvcParamsBuilder<Octs>
where Octs: RefUnwindSafe,

§

impl<Octs> Send for SvcParamsBuilder<Octs>
where Octs: Send,

§

impl<Octs> Sync for SvcParamsBuilder<Octs>
where Octs: Sync,

§

impl<Octs> Unpin for SvcParamsBuilder<Octs>
where Octs: Unpin,

§

impl<Octs> UnwindSafe for SvcParamsBuilder<Octs>
where Octs: 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

source§

type Error = <Target as OctetsFrom<Source>>::Error

source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more