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_directoryoverrides the base directorywith_schemassupplies schemas in memory instead of reading{dir}/schemas/with_callbackregisters a callback that fires on every value refresh.
Implementations§
Source§impl<'a> InitBuilder<'a>
impl<'a> InitBuilder<'a>
pub fn new() -> Self
Sourcepub fn with_directory(self, directory: impl Into<PathBuf>) -> Self
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
Sourcepub fn with_schemas(self, schemas: &'a [(&'a str, &'a str)]) -> Self
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!
Sourcepub fn with_callback(
self,
callback: impl Fn(&str, f64) + Send + Sync + 'static,
) -> Self
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.
Sourcepub fn init(self) -> Result<()>
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().
Sourcepub fn build(self) -> Result<Options>
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.