[−][src]Crate cbor_protocol
Kubos CBOR over UDP communication crate
Examples
use cbor_protocol::*; use serde_cbor::ser; use std::time::Duration; let cbor_connection = Protocol::new(&"0.0.0.0:8000".to_owned(), 4096); let message = ser::to_vec_packed(&("hello", "world")).unwrap(); cbor_connection.send_message(&message, "0.0.0.0:8001".parse().unwrap()).unwrap(); match cbor_connection.recv_message_peer_timeout(Duration::from_millis(10)) { Ok((source, message)) => { println!("Received message from {:?}: {:?}", source, message); } Err(ProtocolError::Timeout) => println!("Timed out waiting for reply"), Err(err) => eprintln!("Failed to receive message: {}", err) }
Structs
Protocol | CBOR protocol communication structure |
Enums
ProtocolError | An error generated during protocol execution |