#[repr(C)]pub struct Args { /* private fields */ }
Expand description
Argument wrapper for connectors
Examples
Construct from a string:
use memflow::plugins::Args;
use std::convert::TryFrom;
let argstr = "opt1=test1,opt2=test2,opt3=test3";
let args: Args = argstr.parse().unwrap();
Construct as builder:
use memflow::plugins::Args;
let args = Args::new()
.insert("arg1", "test1")
.insert("arg2", "test2");
Implementations§
source§impl Args
impl Args
sourcepub fn with_default(value: &str) -> Self
pub fn with_default(value: &str) -> Self
Creates a Args
struct with a default (unnamed) value.
sourcepub fn insert(self, key: &str, value: &str) -> Self
pub fn insert(self, key: &str, value: &str) -> Self
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::plugins::Args;
let args = Args::new()
.insert("arg1", "test1")
.insert("arg2", "test2");
sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Tries to retrieve an entry from the options map.
If the entry was not found this function returns a None
value.
sourcepub fn get_default(&self) -> Option<&str>
pub fn get_default(&self) -> Option<&str>
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§
source§impl<'de> Deserialize<'de> for Args
impl<'de> Deserialize<'de> for Args
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>,
source§impl Display for Args
impl Display for Args
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Generates a string of key-value pairs containing the underlying data of the Args.
This function will produce a string that can be properly parsed by the parse
function again.
Remarks
The sorting order of the underlying HashMap
is random.
This function only guarantees that the ‘default’ value (if it is set) will be the first element.
source§impl FromStr for Args
impl FromStr for Args
source§fn from_str(s: &str) -> Result<Self>
fn from_str(s: &str) -> Result<Self>
Tries to create a Args
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.
Auto Trait Implementations§
impl RefUnwindSafe for Args
impl Send for Args
impl Sync for Args
impl Unpin for Args
impl UnwindSafe for Args
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
source§impl<'a, T> BorrowOwned<'a> for Twhere
T: 'a + Clone,
impl<'a, T> BorrowOwned<'a> for Twhere
T: 'a + Clone,
fn r_borrow( this: &'a <T as BorrowOwned<'a>>::ROwned ) -> <T as BorrowOwned<'a>>::RBorrowed
fn r_to_owned( this: <T as BorrowOwned<'a>>::RBorrowed ) -> <T as BorrowOwned<'a>>::ROwned
fn deref_borrowed(this: &<T as BorrowOwned<'a>>::RBorrowed) -> &T
fn deref_owned(this: &<T as BorrowOwned<'a>>::ROwned) -> &T
fn from_cow_borrow(this: &'a T) -> <T as BorrowOwned<'a>>::RBorrowed
fn from_cow_owned(this: <T as ToOwned>::Owned) -> <T as BorrowOwned<'a>>::ROwned
fn into_cow_borrow(this: <T as BorrowOwned<'a>>::RBorrowed) -> &'a T
fn into_cow_owned(this: <T as BorrowOwned<'a>>::ROwned) -> <T as ToOwned>::Owned
source§impl<T> GetWithMetadata for T
impl<T> GetWithMetadata for T
§type ForSelf = WithMetadata_<T, T>
type ForSelf = WithMetadata_<T, T>
WithMetadata_<Self, Self>
§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read more§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read more§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read more§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read more§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read more§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read more§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
§fn piped_ref<'a, F, U>(&'a self, f: F) -> U
fn piped_ref<'a, F, U>(&'a self, f: F) -> U
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read more§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more