pub struct Params {
inner: BTreeMap<Param, String>,
}
Expand description
An object for handling key=value parameter lists.
The structure is serialized by calling to_string()
on it.
Only for library-internal use.
Fields§
§inner: BTreeMap<Param, String>
Implementations§
source§impl Params
impl Params
sourcepub fn get(&self, key: Param) -> Option<&str>
pub fn get(&self, key: Param) -> Option<&str>
Get the value of the given key, return None
if no value is set.
sourcepub fn set(&mut self, key: Param, value: impl ToString) -> &mut Self
pub fn set(&mut self, key: Param, value: impl ToString) -> &mut Self
Set the given key to the passed in value.
sourcepub fn set_optional(
&mut self,
key: Param,
value: Option<impl ToString>,
) -> &mut Self
pub fn set_optional( &mut self, key: Param, value: Option<impl ToString>, ) -> &mut Self
Sets the given key from an optional value.
Removes the key if the value is None
.
sourcepub fn get_cmd(&self) -> SystemMessage
pub fn get_cmd(&self) -> SystemMessage
Get the parameter behind Param::Cmd
interpreted as SystemMessage
.
sourcepub fn set_cmd(&mut self, value: SystemMessage)
pub fn set_cmd(&mut self, value: SystemMessage)
Set the parameter behind Param::Cmd
.
sourcepub fn get_file<'a>(
&self,
key: Param,
context: &'a Context,
) -> Result<Option<ParamsFile<'a>>>
pub fn get_file<'a>( &self, key: Param, context: &'a Context, ) -> Result<Option<ParamsFile<'a>>>
Gets the given parameter and parse as ParamsFile.
See also Params::get_blob and Params::get_path which may be more convenient.
sourcepub async fn get_blob<'a>(
&self,
key: Param,
context: &'a Context,
) -> Result<Option<BlobObject<'a>>>
pub async fn get_blob<'a>( &self, key: Param, context: &'a Context, ) -> Result<Option<BlobObject<'a>>>
Gets the parameter and returns a BlobObject for it.
This parses the parameter value as a ParamsFile and than tries to return a BlobObject for that file. If the file is not yet a valid blob, one will be created by copying the file.
Note that in the ParamsFile::FsPath case the blob can be created without copying if the path already refers to a valid blob. If so a BlobObject will be returned.
sourcepub fn get_path(&self, key: Param, context: &Context) -> Result<Option<PathBuf>>
pub fn get_path(&self, key: Param, context: &Context) -> Result<Option<PathBuf>>
Gets the parameter and returns a PathBuf for it.
This parses the parameter value as a ParamsFile and returns a PathBuf to the file.
sourcepub fn set_int(&mut self, key: Param, value: i32) -> &mut Self
pub fn set_int(&mut self, key: Param, value: i32) -> &mut Self
Set the given parameter to the passed in i32
.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Params
impl<'de> Deserialize<'de> for Params
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 FromStr for Params
impl FromStr for Params
impl Eq for Params
impl StructuralPartialEq for Params
Auto Trait Implementations§
impl Freeze for Params
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnwindSafe for Params
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.