pub struct FileAccessToken { /* private fields */ }Expand description
A serializable capability token representing access to a user-selected file.
Obtain instances from crate::FilePicker methods. Serialize via
serialize for storage; deserialize to reopen files
across app restarts.
Implementations§
Source§impl FileAccessToken
impl FileAccessToken
Sourcepub fn open_read(&self) -> Result<Box<dyn ReadSeek>, AccessError>
pub fn open_read(&self) -> Result<Box<dyn ReadSeek>, AccessError>
Open the file for reading. Returns Read + Seek.
§Errors
Returns AccessError if permission is revoked or the file cannot be opened.
Sourcepub fn open_write(&self) -> Result<Box<dyn WriteSeek>, AccessError>
pub fn open_write(&self) -> Result<Box<dyn WriteSeek>, AccessError>
Open the file for writing. Returns Write + Seek.
§Errors
Returns AccessError if permission is revoked or the file cannot be opened.
Sourcepub fn display_name(&self) -> &str
pub fn display_name(&self) -> &str
Returns the user-visible display name of the file (typically the filename).
Sourcepub fn mime_type(&self) -> Option<&str>
pub fn mime_type(&self) -> Option<&str>
Returns the MIME type of the file, if known. Desktop returns None.
Sourcepub fn check_permission(&self) -> PermissionStatus
pub fn check_permission(&self) -> PermissionStatus
Check whether the permission grant for this file is still valid.
Sourcepub fn serialize(&self) -> String
pub fn serialize(&self) -> String
Serialize the token to a URL-safe base64-encoded string for storage.
Sourcepub fn deserialize(s: &str) -> Result<Self, TokenParseError>
pub fn deserialize(s: &str) -> Result<Self, TokenParseError>
Deserialize a token from a string previously returned by serialize.
§Errors
Returns TokenParseError if the string is malformed.
Trait Implementations§
Source§impl Clone for FileAccessToken
impl Clone for FileAccessToken
Source§fn clone(&self) -> FileAccessToken
fn clone(&self) -> FileAccessToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileAccessToken
impl Debug for FileAccessToken
Source§impl Display for FileAccessToken
impl Display for FileAccessToken
Auto Trait Implementations§
impl Freeze for FileAccessToken
impl RefUnwindSafe for FileAccessToken
impl Send for FileAccessToken
impl Sync for FileAccessToken
impl Unpin for FileAccessToken
impl UnsafeUnpin for FileAccessToken
impl UnwindSafe for FileAccessToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.