simple_message_channels/
lib.rs

1//! Simple message channels
2//!
3//! A reader and writer for messages in the "simple message channels"(SMC) binary protocol. The
4//! protocol encodes message in a simple pattern of (channel, type, message), where channel can
5//! be any number, type can be any number between 0 and 15, and message can be any byte buffer.
6//!
7//! This is the basic wire protocol used by [hypercore](https://github.com/mafintosh/hypercore).
8//!
9//! This module is a port of the JavaScript module [of the same
10//! name](https://github.com/mafintosh/simple-message-channels/).
11
12mod message;
13mod reader;
14mod writer;
15
16pub use message::Message;
17pub use reader::Reader;
18pub use writer::send;
19pub use writer::send_batch;
20pub use writer::Writer;
21
22/// The max message size (in bytes)
23///
24/// The limit is arbitrary, and taken from the JavaScript implementation.
25/// (see: https://github.com/mafintosh/simple-message-channels/blob/master/index.js)
26/// TODO: This should be configurable.
27pub const MAX_MESSAGE_SIZE: u64 = 1024 * 1024 * 8;