pub struct File { /* private fields */ }
Expand description

A File.

Implementations

Create a new File with the given name and contents.

contents can be &str, &[u8], or js_sys::ArrayBuffer.

Like File::new, but allows customizing the MIME type (also known as content type or media type), and the last modified time.

std::time::SystemTime is a low level type, use a crate like chrono to work with a more user-friendly representation of time.

Examples
use chrono::prelude::*;
use gloo_file::File;

// Just create a dummy `gloo::file::File` for demonstration purposes.
let example_file = File::new_with_options(
    "motivation.txt",
    "live your best life",
    Some("text/plain"),
    Some(Utc::now().into())
);
assert_eq!(example_file.name(), String::from("motivation.txt"));
assert_eq!(example_file.raw_mime_type(), String::from("text/plain"));

Gets the file name.

Gets the time that the file was last modified.

std::time::SystemTime is a low level type, use a crate like chrono to work with more user-friendly representations of time. For example:

use chrono::prelude::*;
use gloo_file::File;

// Just create a dummy `gloo::file::File` for demonstration purposes.
let example_file = File::new("test_file.txt", "<almost empty contents>");
let date: DateTime<Utc> = example_file.last_modified_time().into();

Create a new File from a sub-part of this File.

Methods from Deref<Target = Blob>

The number of bytes in the Blob/File.

The raw MIME type (also known as content type or media type) of the File or Blob.

Trait Implementations

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.