byte_marks/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![deny(elided_lifetimes_in_paths)]
3#![deny(rust_2018_idioms)]
4//! ## byte_marks
5//!
6//! `byte_marks` is a configurable, light weight and intuitive bytes' boundary marker for
7//! transmitting and receiving bytes from network/files. This comes very handy while building
8//! application network protocols - one could read off the demarcated bytes of the wire and
9//! could use bincode <https://github.com/bincode-org/bincode> to reconstruct a struct from those bytes. The demarcating byte pattern
10//! is configured via files called `byte_mark/byte_tail` or environment variables named
11//! similarly and or in code. The characters in the pattern should not repeat.
12//!
13
14use lazy_static::lazy_static;
15use std::env;
16lazy_static! {
17    pub static ref MARK: &'static str = Box::leak({
18        let markings =
19            env::var("byte_mark").unwrap_or_else(|_| include_str!("byte_mark").to_string());
20        markings.into_boxed_str()
21    });
22    pub static ref TAIL: &'static str = Box::leak({
23        let tail = env::var("byte_tail").unwrap_or_else(|_| include_str!("byte_tail").to_string());
24        tail.into_boxed_str()
25    });
26}
27
28pub(crate) type Byte = u8;
29pub use bytemarker::ByteMarker;
30pub use bytemarks::ByteMarks;
31pub use marked::Marked;
32
33mod bytemarker;
34mod bytemarks;
35mod marked;