Pārlūkot izejas kodu

Organize API modules

timvisee 7 gadi atpakaļ
vecāks
revīzija
c32a55c82f

+ 1 - 0
api/src/action/mod.rs

@@ -0,0 +1 @@
+pub mod upload;

+ 4 - 4
api/src/upload.rs → api/src/action/upload.rs

@@ -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 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>;
 pub type Result<T> = ::std::result::Result<T, UploadError>;
 
 

+ 0 - 0
api/src/b64.rs → api/src/crypto/b64.rs


+ 0 - 3
api/src/crypto.rs → api/src/crypto/hdkf.rs

@@ -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.

+ 2 - 2
api/src/key_set.rs → api/src/crypto/key_set.rs

@@ -1,7 +1,7 @@
 use openssl::symm::Cipher;
 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 {
 pub struct KeySet {
     /// A secret.
     /// A secret.

+ 6 - 0
api/src/crypto/mod.rs

@@ -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 - 3
api/src/send_file.rs → api/src/file/file.rs

@@ -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,

+ 1 - 1
api/src/metadata.rs → api/src/file/metadata.rs

@@ -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 - 0
api/src/file/mod.rs

@@ -0,0 +1,2 @@
+pub mod file;
+pub mod metadata;

+ 2 - 5
api/src/lib.rs

@@ -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 metadata;
+pub mod file;
 pub mod reader;
 pub mod reader;
-pub mod send_file;
-pub mod upload;