pub struct RemoteFile { /* private fields */ }
Expand description
A struct representing an uploaded file on a Send host.
The struct contains the file ID, the file URL, the key that is required in combination with the file, and the owner key.
Implementations§
Source§impl RemoteFile
impl RemoteFile
Sourcepub fn new(
id: String,
upload_at: Option<DateTime<Utc>>,
expire_at: Option<DateTime<Utc>>,
host: Url,
url: Url,
secret: Vec<u8>,
owner_token: Option<String>,
) -> Self
pub fn new( id: String, upload_at: Option<DateTime<Utc>>, expire_at: Option<DateTime<Utc>>, host: Url, url: Url, secret: Vec<u8>, owner_token: Option<String>, ) -> Self
Construct a new file.
Sourcepub fn new_now(
id: String,
host: Url,
url: Url,
secret: Vec<u8>,
owner_token: Option<String>,
) -> Self
pub fn new_now( id: String, host: Url, url: Url, secret: Vec<u8>, owner_token: Option<String>, ) -> Self
Construct a new file, that was created at this exact time. This will set the file expiration time
Sourcepub fn parse_url(
url: Url,
owner_token: Option<String>,
) -> Result<RemoteFile, FileParseError>
pub fn parse_url( url: Url, owner_token: Option<String>, ) -> Result<RemoteFile, FileParseError>
Try to parse the given share URL.
The given URL is matched against a share URL pattern, this does not check whether the host is a valid and online host.
If the URL fragmet contains a file secret, it is also parsed. If it does not, the secret is left empty and must be specified manually.
An optional owner token may be given.
Sourcepub fn expire_at(&self) -> DateTime<Utc>
pub fn expire_at(&self) -> DateTime<Utc>
Get the time the file will expire after.
Note that this time may not be correct as it may have been guessed,
see expire_uncertain()
.
Sourcepub fn expire_duration(&self) -> Duration
pub fn expire_duration(&self) -> Duration
Get the duration the file will expire after.
Note that this time may not be correct as it may have been guessed,
see expire_uncertain()
.
Sourcepub fn set_expire_at(&mut self, expire_at: Option<DateTime<Utc>>)
pub fn set_expire_at(&mut self, expire_at: Option<DateTime<Utc>>)
Set the time this file will expire at. None may be given to assign the default expiry time with the uncertainty flag set.
Sourcepub fn set_expire_duration(&mut self, duration: Duration)
pub fn set_expire_duration(&mut self, duration: Duration)
Set the time this file will expire at, based on the given duration from now.
Sourcepub fn has_expired(&self) -> bool
pub fn has_expired(&self) -> bool
Check whether this file has expired, based on it’s expiry property.
Sourcepub fn expire_uncertain(&self) -> bool
pub fn expire_uncertain(&self) -> bool
Check whehter the set expiry time is uncertain. If the expiry time of a file is unknown, the default time is assigned from the first time the file was used. Such time will be uncertain as it probably isn’t correct. This time may be used however to check for expiry.
Sourcepub fn secret_raw(&self) -> &Vec<u8> ⓘ
pub fn secret_raw(&self) -> &Vec<u8> ⓘ
Get the raw secret.
Sourcepub fn set_secret(&mut self, secret: Vec<u8>)
pub fn set_secret(&mut self, secret: Vec<u8>)
Set the secret for this file.
Sourcepub fn has_secret(&self) -> bool
pub fn has_secret(&self) -> bool
Check whether a file secret is set. This secret must be set to decrypt a downloaded Send file.
Sourcepub fn owner_token(&self) -> Option<&String>
pub fn owner_token(&self) -> Option<&String>
Get the owner token if set.
Sourcepub fn owner_token_mut(&mut self) -> &mut Option<String>
pub fn owner_token_mut(&mut self) -> &mut Option<String>
Get the owner token if set.
Sourcepub fn set_owner_token(&mut self, token: Option<String>)
pub fn set_owner_token(&mut self, token: Option<String>)
Set the owner token, wrapped in an option.
If None
is given, the owner token will be unset.
Sourcepub fn has_owner_token(&self) -> bool
pub fn has_owner_token(&self) -> bool
Check whether an owner token is set in this remote file.
Sourcepub fn download_url(&self, secret: bool) -> Url
pub fn download_url(&self, secret: bool) -> Url
Build the download URL of the given file.
This URL is identical to the share URL, a term used in this API.
Set secret
to true
, to include it in the URL if known.
Sourcepub fn merge(&mut self, other: &RemoteFile, overwrite: bool) -> bool
pub fn merge(&mut self, other: &RemoteFile, overwrite: bool) -> bool
Merge properties non-existant into this file, from the given other file. This is ofcourse only done for properties that may be empty.
The file IDs are not asserted for equality.
Trait Implementations§
Source§impl Clone for RemoteFile
impl Clone for RemoteFile
Source§fn clone(&self) -> RemoteFile
fn clone(&self) -> RemoteFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more