launchdarkly_server_sdk_evaluation

Struct MultiContextBuilder

Source
pub struct MultiContextBuilder { /* private fields */ }
Expand description

Contains methods for building a multi-context.

Use this builder if you need to construct a context that has multiple kinds, each representing their own Context. Otherwise, use ContextBuilder.

Obtain an instance of the builder by calling MultiContextBuilder::new; then, call MultiContextBuilder::add_context to add a kind. MultiContextBuilder setters return a reference the same builder, so they can be chained together.

Implementations§

Source§

impl MultiContextBuilder

Source

pub fn new() -> Self

Create a new multi-context builder. An empty builder cannot create a valid Context; you must add one or more kinds via MultiContextBuilder::add_context.

If you already have a list of contexts, you can instead use MultiContextBuilder::of.

Source

pub fn of(contexts: Vec<Context>) -> Self

Create a new multi-context builder from the given list of contexts.

Source

pub fn add_context(&mut self, context: Context) -> &mut Self

Adds a context to the builder.

It is invalid to add more than one context of the same Kind. This error is detected when you call MultiContextBuilder::build.

If context is a multi-context, this is equivalent to adding each individual context.

Source

pub fn build(&self) -> Result<Context, String>

Creates a context from the builder’s current properties.

The context is immutable and will not be affected by any subsequent actions on the MultiContextBuilder.

It is possible for a MultiContextBuilder to represent an invalid state. In those situations, an Err type will be returned.

If only one context was added to the builder, this method returns that context.

Trait Implementations§

Source§

impl Default for MultiContextBuilder

Source§

fn default() -> Self

Creates an empty multi-context builder. In this state, a context must be added in order to build successfully.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.