Commit 69c05c9d authored by Amanjeev Sethi's avatar Amanjeev Sethi

service/files: wip, adds fn advertise_to_user

parent 8d1a1c05
Pipeline #1006 passed with stages
in 5 minutes and 19 seconds
......@@ -1859,6 +1859,7 @@ version = "0.1.0"
dependencies = [
"libqaul",
"mime",
"mime_guess",
"ratman-identity",
"serde",
]
......
......@@ -9,4 +9,5 @@ license = "AGPL-3.0"
identity = { path = "../../../ratman/identity", package = "ratman-identity" }
libqaul = { path = "../../" }
mime = "0.3"
mime_guess = "2.0.1"
serde = { version = "1.0" }
......@@ -2,18 +2,22 @@
use std::sync::Arc;
use mime::Mime;
use libqaul::messages::{Message, MsgQuery};
use libqaul::users::UserAuth;
use libqaul::Identity;
use libqaul::{error::Result, Qaul};
use crate::types::{File, FileFilter, FileId};
pub mod types;
mod protocol;
pub mod types;
// TODO: Partial files
// TODO: file progress
// TODO: Download links with tokens
const ASC_NAME: &'static str = "net.qaul.fileshare";
/// Filesharing service state
......@@ -29,10 +33,7 @@ impl Fileshare {
/// In order to initialise, a valid and running
/// `Qaul` reference needs to be provided.
pub fn new(qaul: Arc<Qaul>, advertised: Arc<Vec<FileId>>) -> Result<Self> {
Ok(Self {
qaul,
advertised,
})
Ok(Self { qaul, advertised })
}
/// Advertise a file into a network
......@@ -41,8 +42,21 @@ impl Fileshare {
file_name: String,
file_id: FileId,
file_size: usize,
file_type: FileFilter, // TODO: use mime crate for file_type
) -> Result<FileId> {
file_type: Mime,
) -> Result<Arc<Vec<FileId>>> {
// returns the `advertised` vector
unimplemented!()
}
// Advertise to a single user
pub fn advertise_to_user(
&self,
file_name: String,
file_size: usize,
file_type: Mime,
send_to: UserAuth,
) -> Result<Arc<Vec<FileId>>> {
unimplemented!()
}
......
......@@ -8,8 +8,10 @@ pub type FileId = Identity;
/// Local file abstraction
pub struct File {
pub name: String,
pub name: Option<String>,
pub id: FileId,
pub data: Option<Vec<u8>>,
pub owner: Identity,
}
/// Describe a file's lifecycle
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment