pub struct Parameters<'s>(/* private fields */);
Expand description
A map of key/value (String,String) parameters.
It can be parsed from a String, using ;
or <newline>
as separator between each parameters
and =
as separator between a key and its value. Keys and values are trimmed.
Example:
use zenoh_protocol::core::Parameters;
let a = "a=1;b=2;c=3|4|5;d=6";
let p = Parameters::from(a);
// Retrieve values
assert!(!p.is_empty());
assert_eq!(p.get("a").unwrap(), "1");
assert_eq!(p.get("b").unwrap(), "2");
assert_eq!(p.get("c").unwrap(), "3|4|5");
assert_eq!(p.get("d").unwrap(), "6");
assert_eq!(p.values("c").collect::<Vec<&str>>(), vec!["3", "4", "5"]);
// Iterate over parameters
let mut iter = p.iter();
assert_eq!(iter.next().unwrap(), ("a", "1"));
assert_eq!(iter.next().unwrap(), ("b", "2"));
assert_eq!(iter.next().unwrap(), ("c", "3|4|5"));
assert_eq!(iter.next().unwrap(), ("d", "6"));
assert!(iter.next().is_none());
// Create parameters from iterators
let pi = Parameters::from_iter(vec![("a", "1"), ("b", "2"), ("c", "3|4|5"), ("d", "6")]);
assert_eq!(p, pi);
Implementations§
Source§impl<'s> Parameters<'s>
impl<'s> Parameters<'s>
Sourcepub fn contains_key<K>(&self, k: K) -> bool
pub fn contains_key<K>(&self, k: K) -> bool
Returns true
if parameters contains the specified key.
Sourcepub fn get<K>(&'s self, k: K) -> Option<&'s str>
pub fn get<K>(&'s self, k: K) -> Option<&'s str>
Returns a reference to the &str
-value corresponding to the key.
Sourcepub fn values<K>(&'s self, k: K) -> impl DoubleEndedIterator<Item = &'s str>
pub fn values<K>(&'s self, k: K) -> impl DoubleEndedIterator<Item = &'s str>
Returns an iterator to the &str
-values corresponding to the key.
Sourcepub fn iter(
&'s self,
) -> impl DoubleEndedIterator<Item = (&'s str, &'s str)> + Clone
pub fn iter( &'s self, ) -> impl DoubleEndedIterator<Item = (&'s str, &'s str)> + Clone
Returns an iterator on the key-value pairs as (&str, &str)
.
Sourcepub fn insert<K, V>(&mut self, k: K, v: V) -> Option<String>
pub fn insert<K, V>(&mut self, k: K, v: V) -> Option<String>
Inserts a key-value pair into the map.
If the map did not have this key present, None
` is returned.
If the map did have this key present, the value is updated, and the old value is returned.
Sourcepub fn remove<K>(&mut self, k: K) -> Option<String>
pub fn remove<K>(&mut self, k: K) -> Option<String>
Removes a key from the map, returning the value at the key if the key was previously in the parameters.
Sourcepub fn extend(&mut self, other: &Parameters<'_>)
pub fn extend(&mut self, other: &Parameters<'_>)
Extend these parameters with other parameters.
Sourcepub fn extend_from_iter<'e, I, K, V>(&mut self, iter: I)
pub fn extend_from_iter<'e, I, K, V>(&mut self, iter: I)
Extend these parameters from an iterator.
Sourcepub fn into_owned(self) -> Parameters<'static>
pub fn into_owned(self) -> Parameters<'static>
Convert these parameters into owned parameters.
Sourcepub fn is_ordered(&self) -> bool
pub fn is_ordered(&self) -> bool
Returns `true`` if all keys are sorted in alphabetical order.
Trait Implementations§
Source§impl<'s> Clone for Parameters<'s>
impl<'s> Clone for Parameters<'s>
Source§fn clone(&self) -> Parameters<'s>
fn clone(&self) -> Parameters<'s>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Parameters<'_>
impl Debug for Parameters<'_>
Source§impl<'s> Default for Parameters<'s>
impl<'s> Default for Parameters<'s>
Source§fn default() -> Parameters<'s>
fn default() -> Parameters<'s>
Source§impl Display for Parameters<'_>
impl Display for Parameters<'_>
Source§impl<'s, K, V> From<&'s [(K, V)]> for Parameters<'_>
impl<'s, K, V> From<&'s [(K, V)]> for Parameters<'_>
Source§impl From<&Parameters<'_>> for HashMap<String, String>
impl From<&Parameters<'_>> for HashMap<String, String>
Source§fn from(props: &Parameters<'_>) -> Self
fn from(props: &Parameters<'_>) -> Self
Source§impl<'a> From<&'a Parameters<'a>> for Cow<'a, Parameters<'a>>
impl<'a> From<&'a Parameters<'a>> for Cow<'a, Parameters<'a>>
Source§fn from(props: &'a Parameters<'a>) -> Self
fn from(props: &'a Parameters<'a>) -> Self
Source§impl<'s> From<&'s Parameters<'s>> for HashMap<&'s str, &'s str>
impl<'s> From<&'s Parameters<'s>> for HashMap<&'s str, &'s str>
Source§fn from(props: &'s Parameters<'s>) -> Self
fn from(props: &'s Parameters<'s>) -> Self
Source§impl<'s> From<&'s Parameters<'s>> for HashMap<Cow<'s, str>, Cow<'s, str>>
impl<'s> From<&'s Parameters<'s>> for HashMap<Cow<'s, str>, Cow<'s, str>>
Source§fn from(props: &'s Parameters<'s>) -> Self
fn from(props: &'s Parameters<'s>) -> Self
Source§impl<'s> From<&'s str> for Parameters<'s>
impl<'s> From<&'s str> for Parameters<'s>
Source§impl<K, V> From<HashMap<K, V>> for Parameters<'_>
impl<K, V> From<HashMap<K, V>> for Parameters<'_>
Source§impl From<Parameters<'_>> for HashMap<String, String>
impl From<Parameters<'_>> for HashMap<String, String>
Source§fn from(props: Parameters<'_>) -> Self
fn from(props: Parameters<'_>) -> Self
Source§impl<'a> From<Parameters<'a>> for Cow<'_, Parameters<'a>>
impl<'a> From<Parameters<'a>> for Cow<'_, Parameters<'a>>
Source§fn from(props: Parameters<'a>) -> Self
fn from(props: Parameters<'a>) -> Self
Source§impl From<String> for Parameters<'_>
impl From<String> for Parameters<'_>
Source§impl<'s, K, V> FromIterator<&'s (K, V)> for Parameters<'_>
impl<'s, K, V> FromIterator<&'s (K, V)> for Parameters<'_>
Source§impl<'s, K, V> FromIterator<(&'s K, &'s V)> for Parameters<'_>
impl<'s, K, V> FromIterator<(&'s K, &'s V)> for Parameters<'_>
Source§impl<'s> Hash for Parameters<'s>
impl<'s> Hash for Parameters<'s>
Source§impl<'s> PartialEq for Parameters<'s>
impl<'s> PartialEq for Parameters<'s>
impl<'s> Eq for Parameters<'s>
impl<'s> StructuralPartialEq for Parameters<'s>
Auto Trait Implementations§
impl<'s> Freeze for Parameters<'s>
impl<'s> RefUnwindSafe for Parameters<'s>
impl<'s> Send for Parameters<'s>
impl<'s> Sync for Parameters<'s>
impl<'s> Unpin for Parameters<'s>
impl<'s> UnwindSafe for Parameters<'s>
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more