Crate channel_protocol
source · [−]Expand description
Channel Protocol
This protocol is used to send and receive CBOR-encoded channel based messages over UDP. Each message consists of three parts: channel ID, message name, message payload, all contained in a cbor array.
{ channel_id, name, payload.. }
The channel ID is typically used to group all messages related to a transaction or logical action. An example would be all messages related to uploading a single file. The message name is used to determine the type of message. The message payload contains any other message data.
Examples
use channel_protocol::*;
let channel_proto = ChannelProtocol::new(
&"0.0.0.0:0".to_owned(),
&"127.0.0.1:8000".to_owned(),
4096);
let message = vec![0, 1, 1, 2];
channel_proto.send(&message);
match channel_proto.recv_message(None) {
Ok(message) => println!("Received: {:?}", message),
Err(e) => eprintln!("Error receiving: {}", e)
}
Structs
Channel message structure
Channel protocol structure
Enums
Errors which occur when using ChannelProtocol
Functions
Generates a new random channel ID for use when initiating a file transfer.
Parse out just the channel ID from a message
Parses raw cbor message into ChannelMessage