No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-09-06 19:35:48 -06:00
.idea hashmap changes 2024-09-06 19:35:48 -06:00
src hashmap changes 2024-09-06 19:35:48 -06:00
.gitignore First Commit 2024-04-18 20:43:38 -06:00
Cargo.lock String encoding 2024-04-19 21:02:58 -06:00
Cargo.toml Changed to library format 2024-04-22 10:14:53 -06:00
LICENSE Create LICENSE 2024-04-22 10:53:14 -06:00
README.md Update README.md 2024-04-24 09:10:18 -06:00

BencodeRust

This is an implementation of Bencode for Rust. Bencode is used for DHTs, Torrents, and Google DataServers. Its a lightweight fast data serialization. Wikipedia

I have also made an implementation of Bencode with Java, JavaScript and PHP.

Implemented Types

Data Structure Default Impl
Vec X Defines own ordering
VecDeque X Defines own ordering
LinkedList X Defines own ordering
HashMap X Ordering missing but content is ordered by key byte representation.
BTreeMap X Defines own ordering
Every Number Type i8-64 u8-64 f32-64 usize
String Types Premitive & Object & u8 array

Usage

Here are some examples of how to use the Bencode library.

Bencode

use crate::variables::bencode_variable::Bencode;
use crate::variables::bencode_object::{BencodeObject, PutObject};

fn main() {
    let mut original = BencodeObject::new();
    original.put("a", "foo");
    original.put("b", "bar");
    original.put("c", 456.78);
    let encoded = original.encode();
    println!("{:?}", encoded);

    let decoded = BencodeObject::decode(encoded);
    println!("{}", decoded.to_string());
}