Struct dogstatsd::OptionsBuilder
source · pub struct OptionsBuilder { /* private fields */ }
Expand description
Struct that allows build an Options
for available for the Dogstatsd client.
Implementations§
source§impl OptionsBuilder
impl OptionsBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new OptionsBuilder
struct.
Examples
use dogstatsd::OptionsBuilder;
let options_builder = OptionsBuilder::new();
sourcepub fn from_addr(&mut self, from_addr: String) -> &mut OptionsBuilder
pub fn from_addr(&mut self, from_addr: String) -> &mut OptionsBuilder
Will allow the builder to generate an Options
struct with the provided value.
Examples
use dogstatsd::OptionsBuilder;
let options_builder = OptionsBuilder::new().from_addr(String::from("127.0.0.1:9000"));
sourcepub fn to_addr(&mut self, to_addr: String) -> &mut OptionsBuilder
pub fn to_addr(&mut self, to_addr: String) -> &mut OptionsBuilder
Will allow the builder to generate an Options
struct with the provided value.
Examples
use dogstatsd::OptionsBuilder;
let options_builder = OptionsBuilder::new().to_addr(String::from("127.0.0.1:9001"));
sourcepub fn namespace(&mut self, namespace: String) -> &mut OptionsBuilder
pub fn namespace(&mut self, namespace: String) -> &mut OptionsBuilder
Will allow the builder to generate an Options
struct with the provided value.
Examples
use dogstatsd::OptionsBuilder;
let options_builder = OptionsBuilder::new().namespace(String::from("mynamespace"));
sourcepub fn default_tag(&mut self, default_tag: String) -> &mut OptionsBuilder
pub fn default_tag(&mut self, default_tag: String) -> &mut OptionsBuilder
Will allow the builder to generate an Options
struct with the provided value. Can be called multiple times to add multiple default_tags
to the Options
.
Examples
use dogstatsd::OptionsBuilder;
let options_builder = OptionsBuilder::new().default_tag(String::from("tag1:tav1val")).default_tag(String::from("tag2:tag2val"));
sourcepub fn build(&self) -> Options
pub fn build(&self) -> Options
Will construct an Options
with all of the provided values and fall back to the default values if they aren’t provided.
Examples
use dogstatsd::OptionsBuilder;
use dogstatsd::Options;
let options = OptionsBuilder::new().namespace(String::from("mynamespace")).default_tag(String::from("tag1:tav1val")).build();
assert_eq!(
Options {
from_addr: "0.0.0.0:0".into(),
to_addr: "127.0.0.1:8125".into(),
namespace: String::from("mynamespace"),
default_tags: vec!(String::from("tag1:tav1val"))
},
options
)
Trait Implementations§
source§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
Auto Trait Implementations§
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