This commit is contained in:
Ondrej Babec
2022-02-25 14:17:58 +01:00
parent 1918930761
commit e660f8ead2
21 changed files with 279 additions and 21 deletions

View File

@@ -1,5 +1,33 @@
use core::fmt::Error;
use core::future::Future;
use crate::packet::mqtt_packet::Packet;
pub enum NetworkError {
Connection,
Unknown,
}
pub trait Network {
fn send(buffer: & mut [u8]);
fn receive(buffer: & mut [u8]);
}
type ConnectionFuture<'m>: Future<Output = Result<(), NetworkError>>
where
Self: 'm;
type WriteFuture<'m>: Future<Output = Result<(), NetworkError>>
where
Self: 'm;
type ReadFuture<'m>: Future<Output = Result<usize, NetworkError>>
where
Self: 'm;
fn new(ip: [u8; 4], port: u16) -> Self;
fn create_connection(& mut self) -> Self::ConnectionFuture<'m>;
fn send(& mut self, buffer: & mut [u8], len: usize) -> Self::WriteFuture<'m>;
fn receive(& mut self, buffer: & mut [u8]) -> Self::ReadFuture<'m>;
}