Enum webc::v2::write::FileEntry

source ·
pub enum FileEntry<'a> {
    Borrowed(&'a [u8]),
    Owned(Bytes),
    Reader(Box<dyn Read>),
}
Expand description

Some file-like object which can be written to a WEBC file.

Variants§

§

Borrowed(&'a [u8])

Bytes borrowed from somewhere else.

§

Owned(Bytes)

Owned bytes.

§

Reader(Box<dyn Read>)

A readable object.

Implementations§

source§

impl FileEntry<'_>

source

pub fn from_path(path: impl Into<PathBuf>) -> Result<Self, Error>

Create a new FileEntry from a file on disk.

To avoid having too many open file handles at a time, the file will only be opened on the first read.

Beware of time-of-check to time-of-use issues. This function checks that the file exists when first called, but permissions may change or the file may still be deleted/moved/replaced before the first read.

Trait Implementations§

source§

impl<'a> Debug for FileEntry<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a [u8]> for FileEntry<'a>

source§

fn from(value: &'a [u8]) -> Self

Converts to this type from the input type.
source§

impl<'a, const N: usize> From<&'a [u8; N]> for FileEntry<'a>

source§

fn from(value: &'a [u8; N]) -> Self

Converts to this type from the input type.
source§

impl<const N: usize> From<[u8; N]> for FileEntry<'_>

source§

fn from(value: [u8; N]) -> Self

Converts to this type from the input type.
source§

impl From<Bytes> for FileEntry<'_>

source§

fn from(value: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<FileEntry> for FileEntry<'_>

source§

fn from(value: FileEntry) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8, Global>> for FileEntry<'_>

source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FileEntry<'a>

§

impl<'a> !Send for FileEntry<'a>

§

impl<'a> !Sync for FileEntry<'a>

§

impl<'a> Unpin for FileEntry<'a>

§

impl<'a> !UnwindSafe for FileEntry<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.