[][src]Struct memflow::connector::args::ConnectorArgs

pub struct ConnectorArgs { /* fields omitted */ }

Argument wrapper for connectors

Examples

Construct from a string:

use memflow::connector::ConnectorArgs;
use std::convert::TryFrom;

let argstr = "opt1=test1,opt2=test2,opt3=test3";
let args = ConnectorArgs::parse(argstr).unwrap();

Construct as builder:

use memflow::connector::ConnectorArgs;

let args = ConnectorArgs::new()
    .insert("arg1", "test1")
    .insert("arg2", "test2");

Implementations

impl ConnectorArgs[src]

pub fn new() -> Self[src]

Creates an empty ConnectorArgs struct.

pub fn with_default(value: &str) -> Self[src]

Creates a ConnectorArgs struct with a default (unnamed) value.

pub fn parse(args: &str) -> Result<Self>[src]

Tries to create a ConnectorArgs structure from an argument string.

The argument string is a string of comma seperated key-value pairs.

An argument string can just contain keys and values: opt1=val1,opt2=val2,opt3=val3

The argument string can also contain a default value as the first entry which will be placed as a default argument: default_value,opt1=val1,opt2=val2

This function can be used to initialize a connector from user input.

pub fn insert(self, key: &str, value: &str) -> Self[src]

Consumes self, inserts the given key-value pair and returns the self again.

This function can be used as a builder pattern when programatically configuring connectors.

Examples

use memflow::connector::ConnectorArgs;

let args = ConnectorArgs::new()
    .insert("arg1", "test1")
    .insert("arg2", "test2");

pub fn get(&self, key: &str) -> Option<&String>[src]

Tries to retrieve an entry from the options map. If the entry was not found this function returns a None value.

pub fn get_default(&self) -> Option<&String>[src]

Tries to retrieve the default entry from the options map. If the entry was not found this function returns a None value.

This function is a convenience wrapper for args.get("default").

Trait Implementations

impl Clone for ConnectorArgs[src]

impl Debug for ConnectorArgs[src]

impl Default for ConnectorArgs[src]

impl<'_> TryFrom<&'_ str> for ConnectorArgs[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<String> for ConnectorArgs[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.