[][src]Struct gloo_file::File

pub struct File { /* fields omitted */ }

A File.

Methods

impl File[src]

pub fn new<T>(name: &str, contents: T) -> File where
    T: BlobContents
[src]

Create a new File with the given name and contents.

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

pub fn new_with_options<T>(
    name: &str,
    contents: T,
    mime_type: Option<&str>,
    last_modified_time: Option<SystemTime>
) -> File where
    T: BlobContents
[src]

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"));

pub fn name(&self) -> String[src]

Gets the file name.

pub fn last_modified_time(&self) -> SystemTime[src]

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();

pub fn slice(&self, start: u64, end: u64) -> Self[src]

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

Methods from Deref<Target = Blob>

pub fn slice(&self, start: u64, end: u64) -> Self[src]

pub fn size(&self) -> u64[src]

The number of bytes in the Blob/File.

pub fn raw_mime_type(&self) -> String[src]

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

Trait Implementations

impl AsRef<Blob> for File[src]

impl AsRef<File> for File[src]

impl Debug for File[src]

impl Deref for File[src]

type Target = Blob

The resulting type after dereferencing.

impl From<File> for File[src]

impl From<File> for Blob[src]

Auto Trait Implementations

impl RefUnwindSafe for File

impl !Send for File

impl !Sync for File

impl Unpin for File

impl UnwindSafe for File

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.