Crates.io | lava_torrent |
lib.rs | lava_torrent |
version | 0.11.1 |
source | src |
created_at | 2018-04-06 02:49:52.055072 |
updated_at | 2023-05-01 07:28:11.628621 |
description | A library for parsing/encoding bencode and .torrent files. |
homepage | |
repository | https://github.com/ttlajus/lava_torrent |
max_upload_size | |
id | 59190 |
size | 933,747 |
lava_torrent
is a library for parsing/encoding/creating bencode and .torrent files.
NOTE: lava_torrent
is now in maintenance mode.
Bugs will still be fixed, but no new features will be released.
If you need something, feel free to fork.
Read a torrent (v1) and print it and its info hash.
use lava_torrent::torrent::v1::Torrent;
let torrent = Torrent::read_from_file("sample.torrent").unwrap();
println!("{}", torrent);
println!("Info hash: {}", torrent.info_hash());
Create a torrent (v1) from files in a directory and save the .torrent file.
use lava_torrent::torrent::v1::TorrentBuilder;
let torrent = TorrentBuilder::new("dir/", 1048576).build().unwrap();
torrent.write_into_file("sample.torrent").unwrap();
Bencode (de)serialization.
use lava_torrent::bencode::BencodeElem;
let bytes = "d4:spam4:eggse".as_bytes();
let dict = BencodeElem::Dictionary([("spam".to_owned(), "eggs".into())].into());
assert_eq!(BencodeElem::from_bytes(bytes).unwrap()[0], dict);
assert_eq!(dict.encode(), bytes);
assert!(dict.write_into_file("/tmp/foo").is_ok());
assert_eq!(BencodeElem::from_file("/tmp/foo").unwrap()[0], dict);
Please check the documentation.
License: MIT OR Apache-2.0