pub struct OptionsBuilder { /* private fields */ }
Expand description

Struct that allows build an Options for available for the Dogstatsd client.

Implementations§

source§

impl OptionsBuilder

source

pub fn new() -> Self

Create a new OptionsBuilder struct.

Examples
  use dogstatsd::OptionsBuilder;

  let options_builder = OptionsBuilder::new();
source

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"));
source

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"));
source

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"));
source

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"));
source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for OptionsBuilder

source§

fn default() -> OptionsBuilder

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.