Skip to main content

InitBuilder

Struct InitBuilder 

Source
pub struct InitBuilder<'a> { /* private fields */ }
Expand description

Builder for initializing the global options store. Define optional parameters with with_* methods, then finalize with init()

All settings are optional and independent:

  • with_directory overrides the base directory
  • with_schemas supplies schemas in memory instead of reading {dir}/schemas/
  • with_callback registers a callback that fires on every value refresh.
  • with_refresh_threshold overrides or disables the staleness threshold for refresh-on-read.

Implementations§

Source§

impl<'a> InitBuilder<'a>

Source

pub fn new() -> Self

Source

pub fn with_directory(self, directory: impl Into<PathBuf>) -> Self

Override the base directory. Expects {directory}/schemas/ and {directory}/values/ subdirectories. Otherwise, defaults to the fallback chain: SENTRY_OPTIONS_DIR env var, then /etc/sentry-options

Source

pub fn with_schemas(self, schemas: &'a [(&'a str, &'a str)]) -> Self

Provide schemas as in-memory (namespace, json) pairs instead of reading them from {dir}/schemas/, intended to be used with include_str!

Source

pub fn with_callback( self, callback: impl Fn(&str, f64) + Send + Sync + 'static, ) -> Self

Register a callback that fires (namespace, delay_secs) whenever values are refreshed with a new generated_at timestamp.

Source

pub fn with_refresh_threshold( self, threshold: impl Into<Option<Duration>>, ) -> Self

Overrides the staleness threshold for refresh-on-read.

Defaults to DEFAULT_REFRESH_THRESHOLD (5 seconds). Pass None to disable refresh-on-read entirely; values then only change via Options::refresh.

Source

pub fn init(self) -> Result<()>

Initialize the global options store from the inputs.

Returns OptionsError::AlreadyInitialized if the store is already initialized, leaving the existing configuration untouched. Callers that want a no-op in that case can ignore the error with .ok().

Source

pub fn build(self) -> Result<Options>

Builds an Options instance from the inputs, without initializing the global store.

Use this when you want to manage the lifetime of the options store yourself, or when you want to have multiple independent options stores in the same process.

Use init if you want to initialize the global store.

Returns an error if the schemas are invalid or the values cannot be loaded.

Trait Implementations§

Source§

impl<'a> Default for InitBuilder<'a>

Source§

fn default() -> InitBuilder<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for InitBuilder<'a>

§

impl<'a> !UnwindSafe for InitBuilder<'a>

§

impl<'a> Freeze for InitBuilder<'a>

§

impl<'a> Send for InitBuilder<'a>

§

impl<'a> Sync for InitBuilder<'a>

§

impl<'a> Unpin for InitBuilder<'a>

§

impl<'a> UnsafeUnpin for InitBuilder<'a>

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> 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<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
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