Struct RemoteFile

Source
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

Source

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.

Source

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

Source

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.

Source

pub fn id(&self) -> &str

Get the file ID.

Source

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

Source

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

Source

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.

Source

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

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

Source

pub fn has_expired(&self) -> bool

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

Source

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.

Source

pub fn url(&self) -> &Url

Get the file URL, provided by the server.

Source

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

Get the raw secret.

Source

pub fn secret(&self) -> String

Get the secret as base64 encoded string.

Source

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

Set the secret for this file.

Source

pub fn has_secret(&self) -> bool

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

Source

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

Get the owner token if set.

Source

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

Get the owner token if set.

Source

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.

Source

pub fn has_owner_token(&self) -> bool

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

Source

pub fn host(&self) -> Url

Get the host URL for this remote file.

Source

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.

Examples found in repository?
examples/upload.rs (line 13)
9fn main() {
10    // Upload the given file, get and report it's share URL
11    let url = upload_file(PathBuf::from("./README.md"))
12        .expect("failed to upload file")
13        .download_url(true);
14    println!("Share URL: {}", url);
15}
Source

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

Source§

fn clone(&self) -> RemoteFile

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RemoteFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RemoteFile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RemoteFile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,