Skip to main content

Crate babbel_bencode

Crate babbel_bencode 

Source
Expand description

A Rust library for encoding and decoding data in the Bencode format, commonly used in BitTorrent files. This library provides functionality to parse, create, modify and serialize bencode data structures with support for various formats including JSON, YAML and XML conversion.

§Features

  • std (default): Enable standard library support
  • Without std: Core bencode functionality works in no_std environments

Re-exports§

pub use misc::get_version as version;
pub use misc::read_bencode_file as read_file;
pub use misc::write_bencode_file as write_file;
pub use nodes::node::Node;
pub use nodes::node::make_node;
pub use nodes::borrowed::BorrowedNode;
pub use nodes::fixed::FixedSizeBuffer;
pub use nodes::fixed::MemoryBounds;
pub use parser::default::parse;
pub use parser::default::parse_bytes;
pub use parser::default::parse_str;
pub use parser::default::parse as from_source;
pub use parser::default::parse_bytes as from_bytes;
pub use parser::default::parse_str as from_str;
pub use parser::borrowed::parse_borrowed;
pub use parser::borrowed::validate_bencode;
pub use parser::iterative::parse_bytes_iterative;
pub use parser::iterative::parse_iterative;
pub use parser::iterative::parse_str_iterative;
pub use memory::Arena;
pub use error::embedded::BencodeError;
pub use config::EncoderConfig;
pub use config::ParserConfig;
pub use stringify::default::stringify;
pub use stringify::default::stringify_to_bytes;
pub use stringify::default::stringify_to_string;
pub use stringify::default::stringify_to_bytes as to_vec;
pub use stringify::default::stringify_to_string as to_string;
pub use io::traits::BencodeWrite;
pub use io::traits::BufferedWrite;
pub use io::traits::RewindableRead;
pub use nodes::query::NodeQueryExt;
pub use stringify::visitor::BencodeVisitable;
pub use stringify::visitor::BencodeVisitor;
pub use stringify::json::stringify as to_json;
pub use stringify::toml::stringify as to_toml;
pub use stringify::xml::stringify as to_xml;
pub use stringify::yaml::stringify as to_yaml;
pub use engine::BencodeEngine;

Modules§

config
Module containing configuration options for parsing and encoding Configuration options for bencode parsing and encoding
engine
Format engine implementation adhering to OCP and DIP Bencode Format Engine adhering to OCP and DIP.
error
Module defining custom error types and error handling functionality
io
Module providing input/output operations for reading and writing bencode data
memory
Module providing memory management utilities for embedded systems Memory pool utilities for embedded systems.
misc
Module containing utility functions and helper methods
nodes
Module defining the core data structures for representing bencode nodes
parser
Module containing the parsing logic to decode bencode format into data structures
stringify
Module implementing serialization of data structures back to bencode format

Macros§

assert_buffer_size
Compile-time assertion that a buffer size is sufficient.

Structs§

BufferDestination
Destination implementation for writing bencode data to a memory buffer In-memory byte buffer destination (Vec<u8>).
BufferSource
Source implementation for reading bencode data from a memory buffer In-memory byte vector input source supporting both binary byte streaming and Unicode UTF-8 character streaming.
FileDestination
Destination implementation for writing bencode data to a file (requires std feature) File output destination writing to a buffered file on disk (32KB write buffer).
FileSource
Source implementation for reading bencode data from a file (requires std feature) File input source reading binary or text data from disk.
MemoryTracker
Memory usage tracker for embedded systems Tracks memory allocations and peak watermarks for resource-constrained environments.
StackBuffer
Stack-based fixed-size buffer Fixed-size stack-allocated byte buffer using const generics.

Traits§

BencodeRead
Core SOLID I/O abstractions Composite interface for raw byte reading (essential for Bencode and binary protocol parsing). Automatically implemented for any type that satisfies IByteReader and IPeekable.