pub struct Upload { /* private fields */ }Expand description
A file upload action to a Send server.
The server API version to use must be given.
Implementations§
Source§impl Upload
impl Upload
Sourcepub fn new(
version: Version,
host: Url,
path: PathBuf,
name: Option<String>,
password: Option<String>,
params: Option<ParamsData>,
) -> Self
pub fn new( version: Version, host: Url, path: PathBuf, name: Option<String>, password: Option<String>, params: Option<ParamsData>, ) -> Self
Construct a new upload action.
Examples found in repository?
examples/upload.rs (lines 29-36)
18fn upload_file(path: PathBuf) -> Result<RemoteFile, Error> {
19 // Build the client for uploading
20 let client_config = ClientConfigBuilder::default().build().unwrap();
21 let client = client_config.client(true);
22
23 #[cfg(feature = "send3")]
24 let version = Version::V3;
25 #[cfg(not(feature = "send3"))]
26 let version = Version::V2;
27
28 // Build upload action, and invoke to upload
29 let upload = Upload::new(
30 version,
31 Url::parse("https://send.firefox.com/").unwrap(),
32 path,
33 None,
34 None,
35 None,
36 );
37 Upload::invoke(upload, &client, None)
38}Sourcepub fn invoke(
self,
client: &Client,
reporter: Option<&Arc<Mutex<dyn ProgressReporter>>>,
) -> Result<RemoteFile, Error>
pub fn invoke( self, client: &Client, reporter: Option<&Arc<Mutex<dyn ProgressReporter>>>, ) -> Result<RemoteFile, Error>
Invoke the upload action.
Examples found in repository?
examples/upload.rs (line 37)
18fn upload_file(path: PathBuf) -> Result<RemoteFile, Error> {
19 // Build the client for uploading
20 let client_config = ClientConfigBuilder::default().build().unwrap();
21 let client = client_config.client(true);
22
23 #[cfg(feature = "send3")]
24 let version = Version::V3;
25 #[cfg(not(feature = "send3"))]
26 let version = Version::V2;
27
28 // Build upload action, and invoke to upload
29 let upload = Upload::new(
30 version,
31 Url::parse("https://send.firefox.com/").unwrap(),
32 path,
33 None,
34 None,
35 None,
36 );
37 Upload::invoke(upload, &client, None)
38}Auto Trait Implementations§
impl Freeze for Upload
impl RefUnwindSafe for Upload
impl Send for Upload
impl Sync for Upload
impl Unpin for Upload
impl UnwindSafe for Upload
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
Mutably borrows from an owned value. Read more