pub struct SensorOptionsBuilder<'a> { /* private fields */ }Expand description
Fluent builder for SensorOptions.
Self::new takes no parameters, every parameter has a fluent setter,
and Self::build validates the mandatory ones — returning
Error::LocalIllegalArgument if they were not set.
Implementations§
Source§impl<'a> SensorOptionsBuilder<'a>
impl<'a> SensorOptionsBuilder<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder with every mandatory parameter unset and every other parameter at the value Java passes on the caller’s behalf.
Sourcepub fn set_name(self, name: &'a str) -> Self
pub fn set_name(self, name: &'a str) -> Self
Sets SensorOptions::name, a mandatory parameter: Self::build
returns an error if it was not set.
§Arguments
name- the sensor’s unique name
§Returns
This builder, for chaining.
Sourcepub fn set_config(self, config: Option<Arc<MetricConfig>>) -> Self
pub fn set_config(self, config: Option<Arc<MetricConfig>>) -> Self
Sourcepub fn set_inactive_sensor_expiration_time_seconds(
self,
inactive_sensor_expiration_time_seconds: i64,
) -> Self
pub fn set_inactive_sensor_expiration_time_seconds( self, inactive_sensor_expiration_time_seconds: i64, ) -> Self
Sourcepub fn set_recording_level(self, recording_level: RecordingLevel) -> Self
pub fn set_recording_level(self, recording_level: RecordingLevel) -> Self
Sourcepub fn set_parents(self, parents: &'a [Arc<Sensor>]) -> Self
pub fn set_parents(self, parents: &'a [Arc<Sensor>]) -> Self
Sourcepub fn build(self) -> Result<SensorOptions<'a>, Error>
pub fn build(self) -> Result<SensorOptions<'a>, Error>
Returns the built options.
The mandatory parameters are validated here rather than being named in
the constructor, so a later Java version that makes one of
them optional changes the set this accepts instead of adding a second
constructor. Today there is one mandatory set: name.
§Errors
Returns Error::LocalIllegalArgument naming the first parameter of that
set which was not given a setter call. Only presence is checked here;
semantic validation belongs to the method the options are passed to.