pub enum Source {
Path(PathBuf),
Url(Url),
Name(String),
}Expand description
The source location for media content (images, audio, video).
Source is an enum, not a struct with a path field. Use pattern matching
to extract the underlying value:
§Accessing the Source
fn get_path_string(source: &Source) -> String {
match source {
Source::Path(path) => path.display().to_string(),
Source::Url(url) => url.to_string(),
Source::Name(name) => name.clone(),
}
}Or use the Display implementation for simple string conversion:
let source_str = source.to_string();§Variants
Path(PathBuf)- Local filesystem path (e.g.,images/photo.png)Url(url::Url)- Remote URL (e.g.,https://example.com/image.png)Name(String)- Simple identifier (e.g., icon names likeheart,github)
Variants§
Path(PathBuf)
A filesystem path (relative or absolute).
Url(Url)
A URL (http, https, ftp, etc.).
Name(String)
A simple name (used for icon names, menu targets, etc.).
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Source
impl<'de> Deserialize<'de> for Source
Source§fn deserialize<D>(deserializer: D) -> Result<Source, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Source, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
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