diff --git a/Cargo.lock b/Cargo.lock index 9eb5e11..9a113a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,7 +67,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -117,33 +117,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -185,11 +185,11 @@ dependencies = [ [[package]] name = "asn1-rs" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" dependencies = [ - "asn1-rs-derive 0.5.0", + "asn1-rs-derive 0.5.1", "asn1-rs-impl 0.2.0", "displaydoc", "nom", @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "asn1-rs-derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", @@ -777,9 +777,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9" dependencies = [ "serde", ] @@ -795,9 +795,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" [[package]] name = "cfg-if" @@ -855,9 +855,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "c53aa12ec67affac065e7c7dd20a42fa2a4094921b655711d5d3107bb3d52bed" dependencies = [ "clap_builder", "clap_derive", @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "efbdf2dd5fe10889e0c61942ff5d948aaf12fd0b4504408ab0cbb1916c2cffa9" dependencies = [ "anstream", "anstyle", @@ -877,9 +877,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -889,15 +889,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "concurrent-queue" @@ -1170,7 +1170,7 @@ version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" dependencies = [ - "asn1-rs 0.6.1", + "asn1-rs 0.6.2", "displaydoc", "nom", "num-bigint", @@ -1552,7 +1552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-pki-types", ] @@ -2008,7 +2008,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-pki-types", "tokio", "tokio-rustls", @@ -2255,9 +2255,9 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -2544,7 +2544,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", - "lru 0.12.3", + "lru 0.12.4", "quick-protobuf", "quick-protobuf-codec 0.3.1", "smallvec", @@ -2759,7 +2759,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.17.8", - "rustls 0.23.11", + "rustls 0.23.12", "socket2 0.5.7", "thiserror", "tokio", @@ -2854,7 +2854,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm-derive", - "lru 0.12.3", + "lru 0.12.4", "multistream-select", "once_cell", "rand 0.8.5", @@ -2926,7 +2926,7 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.17.8", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-webpki 0.101.7", "thiserror", "x509-parser 0.16.0", @@ -3142,9 +3142,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown 0.14.5", ] @@ -3228,13 +3228,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi 0.3.9", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3474,9 +3475,9 @@ checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" [[package]] name = "object" -version = "0.36.1" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -3496,7 +3497,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" dependencies = [ - "asn1-rs 0.6.1", + "asn1-rs 0.6.2", ] [[package]] @@ -3764,9 +3765,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +dependencies = [ + "zerocopy 0.6.6", +] [[package]] name = "primeorder" @@ -3896,7 +3900,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.11", + "rustls 0.23.12", "thiserror", "tokio", "tracing", @@ -3912,7 +3916,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash", - "rustls 0.23.11", + "rustls 0.23.12", "slab", "thiserror", "tinyvec", @@ -3921,9 +3925,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a78e6f726d84fcf960409f509ae354a32648f090c8d32a2ea8b1a1bc3bab14" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" dependencies = [ "libc", "once_cell", @@ -4409,14 +4413,14 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.11" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.5", + "rustls-webpki 0.102.6", "subtle", "zeroize", ] @@ -4458,9 +4462,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.5" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -4613,11 +4617,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -5054,22 +5059,21 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.5.7", "tokio-macros", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5084,9 +5088,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -5109,7 +5113,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.11", + "rustls 0.23.12", "rustls-pki-types", "tokio", ] @@ -5455,9 +5459,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "void" @@ -5866,7 +5870,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" dependencies = [ - "asn1-rs 0.6.1", + "asn1-rs 0.6.2", "data-encoding", "der-parser 9.0.0", "lazy_static", @@ -5932,13 +5936,34 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive 0.6.6", +] + [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] diff --git a/src/cli.rs b/src/cli.rs index 936f545..9a17509 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -23,6 +23,9 @@ pub struct Args { #[arg(short, long, default_value = "8765")] pub port_libp2p: String, + + #[arg(short, long)] + pub owner: Option, } pub fn get_args() -> Args { diff --git a/src/commands/mod.rs b/src/commands/mod.rs index bc89972..1003a26 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -137,7 +137,7 @@ pub async fn start_tunnel_messanger( job_id: job_id.clone(), message: ChannelMessageFromJob::TerminalMessage(stdout), }, - None, + "".to_string(), Some(peer_id.clone()), )) .unwrap(), diff --git a/src/develop/mdns.rs b/src/develop/mdns.rs index 7b5168f..7a81b25 100644 --- a/src/develop/mdns.rs +++ b/src/develop/mdns.rs @@ -113,7 +113,7 @@ async fn start( let mut message = serde_json::from_str::(&msg)?; { let robots_manager = robots.lock().unwrap(); - message.from = Some(robots_manager.self_peer_id.clone()); + message.from = robots_manager.self_peer_id.clone(); } // message.from = Some(std::str::from_utf8(&identity.public().to_bytes())?.to_string()); @@ -167,20 +167,10 @@ async fn start( { let robots_manager = robots.lock().unwrap(); if message_data.to.unwrap_or("".to_string())==robots_manager.self_peer_id{ - match message_data.from{ - Some(sender_peer_id)=>{ - { - let role = robots_manager.get_role(sender_peer_id); - info!("role: {:?}", role); - if matches!(role, RobotRole::OrganizationRobot){ - let _ = to_message_tx.send(message_string); - } - } - - }, - None=>{ - - } + let role = robots_manager.get_role(message_data.from); + info!("role: {:?}", role); + if matches!(role, RobotRole::OrganizationRobot){ + let _ = to_message_tx.send(message_string); } } } diff --git a/src/develop/unix_socket.rs b/src/develop/unix_socket.rs index b785e79..615ad0f 100644 --- a/src/develop/unix_socket.rs +++ b/src/develop/unix_socket.rs @@ -27,8 +27,8 @@ impl MessageQueue { let message_bytes = last_message.as_bytes(); for stream in &mut self.subscribers { - if let Err(_) = stream.try_write(message_bytes) { - error!("Can't write message to socket"); + if let Err(err) = stream.try_write(message_bytes) { + error!("Can't write message to socket {:?}", err); } } } @@ -167,7 +167,7 @@ async fn handle_stream( if let Some(message_content) = command.content { let _ = from_message_tx.send(serde_json::to_string(&Message::new( message_content.content, - None, + "".to_string(), Some(message_content.to), ))?); info!("Sent from unix socket to libp2p"); @@ -183,8 +183,9 @@ async fn handle_stream( message_queue.lock().unwrap().add_subscriber(stream); } } - Err(_err) => { + Err(err) => { error!("Can't deserialize robot message"); + error!("{:?}", err); } } } diff --git a/src/main.rs b/src/main.rs index c9fbe4a..d2e78fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,8 @@ use tracing_subscriber::FmtSubscriber; use crate::store::Message; use crate::store::MessageContent; +use crate::store::MessageRequest; +use crate::store::MessageResponse; use std::sync::{Arc, Mutex}; use tokio::select; use tokio::sync::broadcast; @@ -171,6 +173,30 @@ async fn main_normal( commands::launch_new_job(robot_job, None, agent, shared_jobs).await; }, + MessageContent::MessageRequest(request)=>{ + let mut response_content:Option = None; + match request{ + MessageRequest::ListJobs{}=>{ + info!("ListJobs request"); + let shared_jobs = Arc::clone(&shared_jobs); + let job_manager = shared_jobs.lock().unwrap(); + let jobs = job_manager.get_jobs_info(); + info!("jobs: {:?}", jobs); + response_content = Some(MessageResponse::ListJobs { jobs: jobs }); + }, + _=>{ + + } + } + if let Some(message_response) =response_content{ + let message_content = MessageContent::MessageResponse(message_response); + let _ = from_message_tx.send(serde_json::to_string(&Message::new( + message_content, + "".to_string(), + Some(message.from), + ))?); + } + }, _=>{} } }, diff --git a/src/store.rs b/src/store.rs index ee3728e..2a36d75 100644 --- a/src/store.rs +++ b/src/store.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::error::Error; use std::fs; +use std::hash::Hash; use std::sync::{Arc, Mutex}; use std::time::SystemTime; use tokio::sync::broadcast; @@ -30,10 +31,24 @@ pub enum ChannelMessageFromJob { ArchiveMessage { encoded_tar: String }, } +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "request_type")] +pub enum MessageRequest { + ListJobs {}, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "response_type")] +pub enum MessageResponse { + ListJobs { jobs: Vec }, +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(tag = "type")] pub enum MessageContent { CustomMessage(serde_json::Value), + MessageResponse(MessageResponse), + MessageRequest(MessageRequest), JobMessage(serde_json::Value), StartTunnelReq { job_id: String, @@ -44,6 +59,11 @@ pub enum MessageContent { message: ChannelMessageFromJob, }, StartJob(RobotJob), + UpdateConfig { + config: serde_json::Value, + signer: String, + sign: String, + }, } #[derive(Debug, Clone)] @@ -56,6 +76,23 @@ pub struct JobProcess { pub tunnel: Option, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct JobProcessData { + pub job_id: String, + pub job_type: String, + pub status: String, +} + +impl From for JobProcessData { + fn from(job_process: JobProcess) -> Self { + return Self { + job_id: job_process.job_id, + job_type: job_process.job_type, + status: job_process.status, + }; + } +} + #[derive(Default, Debug)] pub struct JobManager { pub data: HashMap, @@ -84,6 +121,9 @@ impl JobManager { None => None, } } + pub fn get_jobs_info(&self) -> Vec { + return self.data.clone().into_values().map(|x| x.into()).collect(); + } pub fn set_job_status(&mut self, job_id: String, status: String) { let process = self.data.get_mut(&job_id); match process { @@ -140,11 +180,11 @@ impl MessageManager {} pub struct Message { pub timestamp: u128, pub content: MessageContent, - pub from: Option, + pub from: String, pub to: Option, } impl Message { - pub fn new(content: MessageContent, from: Option, to: Option) -> Self { + pub fn new(content: MessageContent, from: String, to: Option) -> Self { let duration_since_epoch = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .unwrap();