[][src]Struct ffsend_api::file::remote_file::RemoteFile

pub struct RemoteFile { /* fields omitted */ }

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.

Methods

impl RemoteFile[src]

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
[src]

Construct a new file.

pub fn new_now(
    id: String,
    host: Url,
    url: Url,
    secret: Vec<u8>,
    owner_token: Option<String>
) -> Self
[src]

Construct a new file, that was created at this exact time. This will set the file expiration time

pub fn parse_url(
    url: Url,
    owner_token: Option<String>
) -> Result<RemoteFile, FileParseError>
[src]

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.

pub fn id(&self) -> &str[src]

Get the file ID.

pub fn expire_at(&self) -> DateTime<Utc>[src]

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

pub fn expire_duration(&self) -> Duration[src]

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

pub fn set_expire_at(&mut self, expire_at: Option<DateTime<Utc>>)[src]

Set the time this file will expire at. None may be given to assign the default expiry time with the uncertainty flag set.

pub fn set_expire_duration(&mut self, duration: Duration)[src]

Set the time this file will expire at, based on the given duration from now.

pub fn has_expired(&self) -> bool[src]

Check whether this file has expired, based on it's expiry property.

pub fn expire_uncertain(&self) -> bool[src]

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.

pub fn url(&self) -> &Url[src]

Get the file URL, provided by the server.

pub fn secret_raw(&self) -> &Vec<u8>[src]

Get the raw secret.

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

Get the secret as base64 encoded string.

pub fn set_secret(&mut self, secret: Vec<u8>)[src]

Set the secret for this file.

pub fn has_secret(&self) -> bool[src]

Check whether a file secret is set. This secret must be set to decrypt a downloaded Send file.

pub fn owner_token(&self) -> Option<&String>[src]

Get the owner token if set.

pub fn owner_token_mut(&mut self) -> &mut Option<String>[src]

Get the owner token if set.

pub fn set_owner_token(&mut self, token: Option<String>)[src]

Set the owner token, wrapped in an option. If None is given, the owner token will be unset.

pub fn has_owner_token(&self) -> bool[src]

Check whether an owner token is set in this remote file.

pub fn host(&self) -> Url[src]

Get the host URL for this remote file.

pub fn download_url(&self, secret: bool) -> Url[src]

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.

pub fn merge(&mut self, other: &RemoteFile, overwrite: bool) -> bool[src]

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

impl Clone for RemoteFile[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for RemoteFile[src]

impl Serialize for RemoteFile[src]

impl<'de> Deserialize<'de> for RemoteFile[src]

Auto Trait Implementations

impl Send for RemoteFile

impl Sync for RemoteFile

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<T> Typeable for T where
    T: Any

default fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> Same for T

type Output = T

Should always be Self