mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-03 09:39:15 +02:00
Organize API modules
This commit is contained in:
parent
7a56dabd39
commit
c32a55c82f
10 changed files with 21 additions and 18 deletions
1
api/src/action/mod.rs
Normal file
1
api/src/action/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod upload;
|
|
@ -10,10 +10,10 @@ use reqwest::mime::APPLICATION_OCTET_STREAM;
|
||||||
use reqwest::multipart::Part;
|
use reqwest::multipart::Part;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use super::key_set::KeySet;
|
use crypto::key_set::KeySet;
|
||||||
use super::metadata::{Metadata, XFileMetadata};
|
use reader::EncryptedFileReaderTagged;
|
||||||
use super::reader::EncryptedFileReaderTagged;
|
use file::file::File as SendFile;
|
||||||
use super::send_file::SendFile;
|
use file::metadata::{Metadata, XFileMetadata};
|
||||||
|
|
||||||
pub type Result<T> = ::std::result::Result<T, UploadError>;
|
pub type Result<T> = ::std::result::Result<T, UploadError>;
|
||||||
|
|
|
@ -4,9 +4,6 @@ extern crate sha2;
|
||||||
use self::hkdf::Hkdf;
|
use self::hkdf::Hkdf;
|
||||||
use self::sha2::Sha256;
|
use self::sha2::Sha256;
|
||||||
|
|
||||||
// Reexport the cryptographically secure random bytes generator
|
|
||||||
pub use super::openssl::rand::rand_bytes;
|
|
||||||
|
|
||||||
/// Derive a HKDF key.
|
/// Derive a HKDF key.
|
||||||
///
|
///
|
||||||
/// No _salt_ bytes are used in this function.
|
/// No _salt_ bytes are used in this function.
|
|
@ -1,7 +1,7 @@
|
||||||
use openssl::symm::Cipher;
|
use openssl::symm::Cipher;
|
||||||
|
|
||||||
use b64;
|
use super::{b64, rand_bytes};
|
||||||
use crypto::{derive_auth_key, derive_file_key, derive_meta_key, rand_bytes};
|
use super::hdkf::{derive_auth_key, derive_file_key, derive_meta_key};
|
||||||
|
|
||||||
pub struct KeySet {
|
pub struct KeySet {
|
||||||
/// A secret.
|
/// A secret.
|
6
api/src/crypto/mod.rs
Normal file
6
api/src/crypto/mod.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
pub mod b64;
|
||||||
|
pub mod hdkf;
|
||||||
|
pub mod key_set;
|
||||||
|
|
||||||
|
// Reexport the cryptographically secure random bytes generator
|
||||||
|
pub use super::openssl::rand::rand_bytes;
|
|
@ -3,14 +3,14 @@ extern crate chrono;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use self::chrono::{DateTime, Utc};
|
use self::chrono::{DateTime, Utc};
|
||||||
|
|
||||||
use b64;
|
use crypto::b64;
|
||||||
|
|
||||||
/// A struct representing an uploaded file on a Send host.
|
/// A struct representing an uploaded file on a Send host.
|
||||||
///
|
///
|
||||||
/// The struct contains the file ID, the file URL, the key that is required
|
/// The struct contains the file ID, the file URL, the key that is required
|
||||||
/// in combination with the file, and the owner key.
|
/// in combination with the file, and the owner key.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SendFile {
|
pub struct File {
|
||||||
/// The ID of the file on that server.
|
/// The ID of the file on that server.
|
||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ pub struct SendFile {
|
||||||
owner_key: String,
|
owner_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SendFile {
|
impl File {
|
||||||
/// Construct a new file.
|
/// Construct a new file.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
id: String,
|
id: String,
|
|
@ -11,7 +11,7 @@ use reqwest::header::{
|
||||||
};
|
};
|
||||||
use self::hyper::error::Error as HyperError;
|
use self::hyper::error::Error as HyperError;
|
||||||
|
|
||||||
use b64;
|
use crypto::b64;
|
||||||
|
|
||||||
/// File metadata, which is send to the server.
|
/// File metadata, which is send to the server.
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
2
api/src/file/mod.rs
Normal file
2
api/src/file/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod file;
|
||||||
|
pub mod metadata;
|
|
@ -5,10 +5,7 @@ pub extern crate url;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
pub mod b64;
|
pub mod action;
|
||||||
pub mod crypto;
|
pub mod crypto;
|
||||||
pub mod key_set;
|
pub mod file;
|
||||||
pub mod metadata;
|
|
||||||
pub mod reader;
|
pub mod reader;
|
||||||
pub mod send_file;
|
|
||||||
pub mod upload;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue