pub struct HydraClient<R> { /* private fields */ }Expand description
HydraClient connects to the relay server as a producer or consumer, performs handshake, and sends/receives encrypted frames.
It maintains an internal memory pool (18 mb) for zero-copy crypto and buffering.
The broadcast method allows producers to send encrypted frames to all connected consumers in the same session,
while the recv method allows consumers to receive and decrypt frames from the producer.
use hydra_sync::client::{HydraClient, Producer, Consumer};
#[tokio::main]
async fn main() {
let addr = "127.0.0.1:8000";
let session_id = [0xFFu8; 64];
let session_key = [0xAAu8; 32];
let mut producer = HydraClient::<Producer>::connect(addr, &session_id, session_key).await.unwrap();
producer.broadcast(b"I luv you >.<").await.unwrap(); // sends to all consumer
let mut consumer = HydraClient::<Consumer>::connect(addr, &session_id, session_key).await.unwrap();
consumer.recv().await.unwrap(); // recv whatever next frame on ring buf
}Implementations§
Source§impl HydraClient<Producer>
impl HydraClient<Producer>
Auto Trait Implementations§
impl<R> Freeze for HydraClient<R>
impl<R> RefUnwindSafe for HydraClient<R>where
R: RefUnwindSafe,
impl<R> Send for HydraClient<R>where
R: Send,
impl<R> Sync for HydraClient<R>where
R: Sync,
impl<R> Unpin for HydraClient<R>where
R: Unpin,
impl<R> UnsafeUnpin for HydraClient<R>
impl<R> UnwindSafe for HydraClient<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more