pub enum FileSource {
Path(PathBuf),
Url(String),
Bytes(Bytes),
Temp(TempFile),
}Expand description
A reference to file content that can be read. Does NOT load content eagerly — all reads are lazy/streamed.
Serialization notes:
Tempserializes asPath(temp file’s path).Bytesserializes as a byte array.- Deserialized
TempbecomesPath(temp ownership is not restored).
Variants§
Path(PathBuf)
Local filesystem path.
Url(String)
Remote URL (will be streamed on read, not eagerly downloaded).
Bytes(Bytes)
In-memory bytes (for small files or test fixtures).
Temp(TempFile)
Managed temporary file (auto-deleted on drop).
Implementations§
Source§impl FileSource
impl FileSource
Sourcepub fn from_bytes(b: impl Into<Bytes>) -> Self
pub fn from_bytes(b: impl Into<Bytes>) -> Self
Create a source from in-memory bytes.
Sourcepub async fn reader(&self) -> AppResult<Box<dyn AsyncRead + Send + Unpin>>
pub async fn reader(&self) -> AppResult<Box<dyn AsyncRead + Send + Unpin>>
Open an async reader over this source.
Sourcepub async fn stream(
&self,
) -> AppResult<impl Stream<Item = AppResult<Bytes>> + '_>
pub async fn stream( &self, ) -> AppResult<impl Stream<Item = AppResult<Bytes>> + '_>
Open a byte stream over this source.
Sourcepub async fn read_all(&self) -> AppResult<Bytes>
pub async fn read_all(&self) -> AppResult<Bytes>
Read entire content into memory (use only for small files).
Sourcepub async fn to_local_path(&self) -> AppResult<ResolvedPath>
pub async fn to_local_path(&self) -> AppResult<ResolvedPath>
Resolve to a local file path. Downloads to temp if source is URL/Bytes.
Trait Implementations§
Source§impl Clone for FileSource
impl Clone for FileSource
Source§impl Debug for FileSource
impl Debug for FileSource
Source§impl<'de> Deserialize<'de> for FileSource
impl<'de> Deserialize<'de> for FileSource
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for FileSource
impl RefUnwindSafe for FileSource
impl Send for FileSource
impl Sync for FileSource
impl Unpin for FileSource
impl UnsafeUnpin for FileSource
impl UnwindSafe for FileSource
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