[−][src]Struct gloo_file::File
A File
.
Methods
impl File
[src]
pub fn new<T>(name: &str, contents: T) -> File where
T: BlobContents,
[src]
T: BlobContents,
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]
name: &str,
contents: T,
mime_type: Option<&str>,
last_modified_time: Option<SystemTime>
) -> File where
T: BlobContents,
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]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,