Skip to main content

VirtualFile

Struct VirtualFile 

Source
pub struct VirtualFile { /* private fields */ }
Expand description

Describes one virtual file exposed to a receiving application.

A virtual file consists of a name, an optional known size, and a crate::FileSource that supplies its contents on demand. The file need not exist as a physical file on the source machine.

Implementations§

Source§

impl VirtualFile

Source

pub fn new(name: &str, source: Box<dyn FileSource>) -> Result<Self>

Creates a virtual file with an unknown size.

name may be a relative path such as reports/2026/report.txt. The name and its path components are validated for the target platform. A separate transfer-level check rejects duplicate or conflicting paths.

§Errors

Returns crate::Error::InvalidInput when the name is empty or invalid.

Source

pub fn name(&self) -> &str

Returns the virtual file’s name or relative destination path.

Source

pub fn size(&self) -> Option<u64>

Returns the explicitly supplied size, if any.

None does not imply an empty file. A seekable source may still provide its length when opened by the receiving application.

Source

pub fn with_size(self, size: u64) -> Self

Sets the advertised size in bytes and returns the updated file.

This does not inspect the source. The caller is responsible for ensuring the declared size matches the bytes the source provides.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.