pub struct Parameter {
pub key: ParameterKey,
pub value: ParameterValue,
}Fields§
§key: ParameterKey§value: ParameterValueTrait Implementations§
Source§impl FromStr for Parameter
impl FromStr for Parameter
Source§fn from_str(input: &str) -> Result<Parameter, Self::Err>
fn from_str(input: &str) -> Result<Parameter, Self::Err>
Parse parameter from string
§Examples
Success, both present
assert_eq!(
Ok(Parameter {
key: ParameterKey(String::from("some-key")),
value: ParameterValue(String::from("some-value")),
}),
std::str::FromStr::from_str("some-key:some-value")
)Success, empty value
assert_eq!(
Ok(Parameter {
key: ParameterKey(String::from("some-key")),
value: ParameterValue(String::from("")),
}),
std::str::FromStr::from_str("some-key:")
)Missing delimiter
assert_eq!(
Err("missing ':' in input"),
<Parameter as std::str::FromStr>::from_str("some-key")
)Empty key
assert_eq!(
Err("parameter key cannot be empty"),
<Parameter as std::str::FromStr>::from_str(":value")
)Overlong key
assert_eq!(
Err("parameter key cannot be longer than 255 bytes"),
<Parameter as std::str::FromStr>::from_str(&("a".repeat(256) + ":"))
)Overlong value
assert_eq!(
Err("parameter value cannot be longer than 4096 bytes"),
<Parameter as std::str::FromStr>::from_str(&("a:".to_owned() + &"b".repeat(4097)))
)impl Eq for Parameter
impl StructuralPartialEq for Parameter
Auto Trait Implementations§
impl Freeze for Parameter
impl RefUnwindSafe for Parameter
impl Send for Parameter
impl Sync for Parameter
impl Unpin for Parameter
impl UnsafeUnpin for Parameter
impl UnwindSafe for Parameter
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
Mutably borrows from an owned value. Read more
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.