pub enum StringOrUrl {
Url(Url),
String(String),
}
Expand description
A type that represents either an arbitrary string or a URL.
Variants§
Implementations§
Source§impl StringOrUrl
impl StringOrUrl
Sourcepub fn parse(s: &str) -> Result<Self, Infallible>
pub fn parse(s: &str) -> Result<Self, Infallible>
Parses a StringOrUrl
from a string.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns a str
reference if self
is StringOrUrl::String
.
Sourcepub fn is_url(&self) -> bool
pub fn is_url(&self) -> bool
Returns whether self
is a StringOrUrl::Url
.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Returns whether self
is a StringOrUrl::String
.
Trait Implementations§
Source§impl AsRef<str> for StringOrUrl
impl AsRef<str> for StringOrUrl
Source§impl Clone for StringOrUrl
impl Clone for StringOrUrl
Source§fn clone(&self) -> StringOrUrl
fn clone(&self) -> StringOrUrl
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for StringOrUrl
impl Debug for StringOrUrl
Source§impl Default for StringOrUrl
impl Default for StringOrUrl
Source§impl<'de> Deserialize<'de> for StringOrUrl
impl<'de> Deserialize<'de> for StringOrUrl
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for StringOrUrl
impl Display for StringOrUrl
Source§impl From<String> for StringOrUrl
impl From<String> for StringOrUrl
Source§impl From<StringOrUrl> for String
impl From<StringOrUrl> for String
Source§fn from(value: StringOrUrl) -> Self
fn from(value: StringOrUrl) -> Self
Converts to this type from the input type.
Source§impl From<Url> for StringOrUrl
impl From<Url> for StringOrUrl
Source§impl FromStr for StringOrUrl
impl FromStr for StringOrUrl
Source§impl Hash for StringOrUrl
impl Hash for StringOrUrl
Source§impl Ord for StringOrUrl
impl Ord for StringOrUrl
Source§fn cmp(&self, other: &StringOrUrl) -> Ordering
fn cmp(&self, other: &StringOrUrl) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for StringOrUrl
impl PartialEq for StringOrUrl
Source§impl PartialOrd for StringOrUrl
impl PartialOrd for StringOrUrl
Source§impl Serialize for StringOrUrl
impl Serialize for StringOrUrl
impl Eq for StringOrUrl
impl StructuralPartialEq for StringOrUrl
Auto Trait Implementations§
impl Freeze for StringOrUrl
impl RefUnwindSafe for StringOrUrl
impl Send for StringOrUrl
impl Sync for StringOrUrl
impl Unpin for StringOrUrl
impl UnwindSafe for StringOrUrl
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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
Compare self to
key
and return true
if they are equal.Source§impl<T> FromJson for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromJson for Twhere
T: for<'de> Deserialize<'de>,
Source§fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self>
fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self>
Deserialize
Self
from a string of JSON text.Source§fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self>
fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self>
Deserialize
Self
from bytes of JSON text.Source§fn from_json_value(json: Value) -> Result<Self>
fn from_json_value(json: Value) -> Result<Self>
Deserialize
Self
from a serde_json::Value
.Source§impl<T> ToJson for Twhere
T: Serialize,
impl<T> ToJson for Twhere
T: Serialize,
Source§fn to_json_value(&self) -> Result<Value>
fn to_json_value(&self) -> Result<Value>
Serialize
self
as a serde_json::Value
.Source§fn to_json_pretty(&self) -> Result<String>
fn to_json_pretty(&self) -> Result<String>
Serialize
self
as a pretty-printed string of JSON.