Skip to main content

MemoryFile

Struct MemoryFile 

Source
pub struct MemoryFile(/* private fields */);
Expand description

A file in memory, given as a handle. When writable, a writer’s writes land only once it finishes, and a writer dropped before abandons them, as the web’s do. Every clone is the same file.

Implementations§

Source§

impl MemoryFile

Source

pub fn new(name: impl Into<String>, bytes: impl Into<Vec<u8>>) -> MemoryFile

A read-only file named name holding bytes.

Source

pub fn writable(self) -> MemoryFile

The same file, writable.

Source

pub fn contents(&self) -> Vec<u8> ⓘ

What the file holds now.

Source

pub fn picked(&self) -> PickedFile

The file as a pick.

Trait Implementations§

Source§

impl Clone for MemoryFile

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl FileHandle for MemoryFile

Source§

fn url(&self) -> String

memory: and the file’s name, which no system reads: a test’s stand-in for a URL.

Source§

fn name(&self) -> &str

The file’s name, which the user sees.
Source§

fn size(&self) -> FileSizeFuture

Source§

fn read_at<'a>(&'a self, offset: u64, buf: &'a mut [u8]) -> FileReadFuture<'a>

Reads into buf from offset; answers how many bytes it read, 0 at the end.
Source§

fn open_write(&self) -> Option<FileOpenFuture<Box<dyn FileWriter>>>

Opens the file to write; None unless the pick is writable.

Auto Trait Implementations§

§

impl !RefUnwindSafe for MemoryFile

§

impl !Send for MemoryFile

§

impl !Sync for MemoryFile

§

impl !UnwindSafe for MemoryFile

§

impl Forget for MemoryFile

§

impl Freeze for MemoryFile
where *const RcInner<MemoryFileState> is !null: Freeze, PhantomData<RcInner<MemoryFileState>>: Freeze,

§

impl Move for MemoryFile

§

impl Unpin for MemoryFile
where Rc<MemoryFileState>: Unpin,

§

impl UnsafeUnpin for MemoryFile
where *const RcInner<MemoryFileState> is !null: UnsafeUnpin, PhantomData<RcInner<MemoryFileState>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>