pub enum Source {
Stdin,
Path(PathBuf),
Url(Url),
}
Expand description
A source for data that needs to be deserialized.
Variants§
Implementations§
Source§impl Source
impl Source
Sourcepub fn as_path(&self) -> Option<&Path>
pub fn as_path(&self) -> Option<&Path>
Returns Some
if the source is a local path, None
otherwise.
Sourcepub fn is_dir(&self) -> bool
pub fn is_dir(&self) -> bool
Returns true
if the Source
is a local path and the path exists on disk and is pointing
at a directory.
Sourcepub fn encoding(&self) -> Option<Encoding>
pub fn encoding(&self) -> Option<Encoding>
Tries to detect the encoding of the source. Returns None
if the encoding cannot be
detected.
Sourcepub fn glob_files(&self, pattern: &str) -> Result<Vec<Source>>
pub fn glob_files(&self, pattern: &str) -> Result<Vec<Source>>
If source is a local path, this returns sources for all files matching the glob pattern.
§Errors
Returns an error if the sink is not of variant Sink::Path
, the pattern is invalid or if
there is a io::Error
while reading the file system.
Sourcepub fn to_reader(&self) -> Result<SourceReader>
pub fn to_reader(&self) -> Result<SourceReader>
Returns a SourceReader
to read from the source.
§Errors
May return an error if the source is Source::Path
and the file cannot be opened of if
source is Source::Url
and there is an error requesting the remote url.
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more