pub struct OptionsBuilder { /* private fields */ }
Expand description
OptionsBuilder
is a helper structure used to construct Options
in a flexible way.
OptionsBuilder
follows the builder pattern, providing a fluent interface to add options
and finally, build an Options
instance. This pattern is used to handle cases where the Options
instance may require complex configuration or optional fields.
§Example
let mut builder = OptionsBuilder::new();
builder.add_option(Opt::Model(ModelRef::from_path("path_to_model")));
let options = builder.build();
Implementations§
Source§impl OptionsBuilder
impl OptionsBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new, empty OptionsBuilder
.
Returns an OptionsBuilder
instance with an empty opts
field.
§Example
let builder = OptionsBuilder::new();
Sourcepub fn add_option(&mut self, opt: Opt)
pub fn add_option(&mut self, opt: Opt)
Sourcepub fn build(self) -> Options
pub fn build(self) -> Options
Consumes the OptionsBuilder
, returning an Options
instance.
This function consumes the OptionsBuilder
, moving its opts
field to a new Options
instance.
§Returns
An Options
instance with the options added through the builder.
§Example
let mut builder = OptionsBuilder::new();
builder.add_option(Opt::Model(ModelRef::from_path("path_to_model")));
let options = builder.build();
Trait Implementations§
Source§impl Clone for OptionsBuilder
impl Clone for OptionsBuilder
Source§fn clone(&self) -> OptionsBuilder
fn clone(&self) -> OptionsBuilder
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for OptionsBuilder
impl Debug for OptionsBuilder
Source§impl Default for OptionsBuilder
impl Default for OptionsBuilder
Source§fn default() -> OptionsBuilder
fn default() -> OptionsBuilder
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OptionsBuilder
impl<'de> Deserialize<'de> for OptionsBuilder
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for OptionsBuilder
impl RefUnwindSafe for OptionsBuilder
impl Send for OptionsBuilder
impl Sync for OptionsBuilder
impl Unpin for OptionsBuilder
impl UnwindSafe for OptionsBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more