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 url::Url;
|
||||
|
||||
use super::key_set::KeySet;
|
||||
use super::metadata::{Metadata, XFileMetadata};
|
||||
use super::reader::EncryptedFileReaderTagged;
|
||||
use super::send_file::SendFile;
|
||||
use crypto::key_set::KeySet;
|
||||
use reader::EncryptedFileReaderTagged;
|
||||
use file::file::File as SendFile;
|
||||
use file::metadata::{Metadata, XFileMetadata};
|
||||
|
||||
pub type Result<T> = ::std::result::Result<T, UploadError>;
|
||||
|
|
@ -4,9 +4,6 @@ extern crate sha2;
|
|||
use self::hkdf::Hkdf;
|
||||
use self::sha2::Sha256;
|
||||
|
||||
// Reexport the cryptographically secure random bytes generator
|
||||
pub use super::openssl::rand::rand_bytes;
|
||||
|
||||
/// Derive a HKDF key.
|
||||
///
|
||||
/// No _salt_ bytes are used in this function.
|
|
@ -1,7 +1,7 @@
|
|||
use openssl::symm::Cipher;
|
||||
|
||||
use b64;
|
||||
use crypto::{derive_auth_key, derive_file_key, derive_meta_key, rand_bytes};
|
||||
use super::{b64, rand_bytes};
|
||||
use super::hdkf::{derive_auth_key, derive_file_key, derive_meta_key};
|
||||
|
||||
pub struct KeySet {
|
||||
/// 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 self::chrono::{DateTime, Utc};
|
||||
|
||||
use b64;
|
||||
use crypto::b64;
|
||||
|
||||
/// 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.
|
||||
#[derive(Debug)]
|
||||
pub struct SendFile {
|
||||
pub struct File {
|
||||
/// The ID of the file on that server.
|
||||
id: String,
|
||||
|
||||
|
@ -30,7 +30,7 @@ pub struct SendFile {
|
|||
owner_key: String,
|
||||
}
|
||||
|
||||
impl SendFile {
|
||||
impl File {
|
||||
/// Construct a new file.
|
||||
pub fn new(
|
||||
id: String,
|
|
@ -11,7 +11,7 @@ use reqwest::header::{
|
|||
};
|
||||
use self::hyper::error::Error as HyperError;
|
||||
|
||||
use b64;
|
||||
use crypto::b64;
|
||||
|
||||
/// File metadata, which is send to the server.
|
||||
#[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]
|
||||
extern crate serde_derive;
|
||||
|
||||
pub mod b64;
|
||||
pub mod action;
|
||||
pub mod crypto;
|
||||
pub mod key_set;
|
||||
pub mod metadata;
|
||||
pub mod file;
|
||||
pub mod reader;
|
||||
pub mod send_file;
|
||||
pub mod upload;
|
||||
|
|
Loading…
Add table
Reference in a new issue