ennucore
5 years ago
5 changed files with 86 additions and 47 deletions
@ -1,14 +1,33 @@
|
||||
use crate::transport::Transport; |
||||
use crate::crypto::{PublicKey, KeyPack}; |
||||
use crate::message::{Message, MsgType}; |
||||
|
||||
use alloc::vec::Vec; |
||||
|
||||
|
||||
pub struct IronForce { |
||||
transport: Transport, |
||||
key_pack: KeyPack |
||||
key_pack: KeyPack, |
||||
} |
||||
|
||||
impl IronForce { |
||||
pub fn gen() -> IronForce { |
||||
pub fn new() -> IronForce { |
||||
IronForce { transport: Transport {}, key_pack: KeyPack::gen() } |
||||
} |
||||
|
||||
fn new_message(&self, msg_type: MsgType, body: Vec<u8>) -> Message { |
||||
Message::new(msg_type, body, &self.key_pack) |
||||
} |
||||
|
||||
fn service_msg(&self, body: Vec<u8>) { |
||||
self.transport.send(&self.new_message(MsgType::Service, body)) |
||||
} |
||||
|
||||
pub fn multicast(&self, body: Vec<u8>) { |
||||
self.transport.send(&self.new_message(MsgType::MultiCast, body)) |
||||
} |
||||
|
||||
pub fn send_message_to(&self, to: PublicKey, body: Vec<u8>) { |
||||
self.transport.send(&self.new_message(MsgType::ToTarget(to), body)) |
||||
} |
||||
} |
||||
|
@ -1,2 +1,16 @@
|
||||
use crate::message::{Message, MsgType}; |
||||
use alloc::vec::Vec; |
||||
|
||||
pub(crate) struct Transport {} |
||||
pub struct Transport {} |
||||
|
||||
impl Transport { |
||||
pub fn send(&self, msg: &Message) { |
||||
|
||||
} |
||||
|
||||
pub fn receive(&self) -> Message { |
||||
Message::new(MsgType::Service, |
||||
Vec::<u8>::new(), |
||||
&crate::crypto::KeyPack::gen()) |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue