Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
chore: undo package rename
Browse files Browse the repository at this point in the history
THe initial intention was to mantain a fork, but finally we will merge
the fork changes into the upstream repo.
  • Loading branch information
josecelano committed Oct 9, 2023
1 parent 9833274 commit f58baf7
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 30 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "torrust-serde-bencode"
name = "serde_bencode"
description = "A Serde backed Bencode encoding/decoding library for Rust."
version = "0.2.3"
authors = ["Toby Padilla <tobypadilla@gmail.com>", "Nautilus Cyberneering <info@nautilus-cyberneering.de>"]
repository = "https://github.com/torrust/torrust-serde-bencode"
documentation = "https://docs.rs/torrust-serde-bencode/"
repository = "https://github.com/toby/serde-bencode"
documentation = "https://docs.rs/serde_bencode/"
license = "MIT"
keywords = ["bencode", "serialize", "deserialize", "serde"]
edition = "2018"
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Torrust Serde Bencode

[![Checking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml) [![Formatting](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml) [![Testing](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml) [![Benchmarking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml) [![Coverage](https://github.com/torrust/torrust-serde-bencode/actions/workflows/coverage.yaml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/coverage.yaml)
[![Checking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/checking.yml) [![Formatting](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/formatting.yml) [![Testing](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/testing.yaml) [![Benchmarking](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/benchmarking.yml) [![Coverage](https://github.com/torrust/torrust-serde-bencode/actions/workflows/coverage.yaml/badge.svg)](https://github.com/torrust/torrust-serde-bencode/actions/workflows/coverage.yaml) [![Crates.io](https://img.shields.io/crates/v/serde_bencode)](https://crates.io/crates/serde_bencode) [![docs.rs](https://img.shields.io/docsrs/serde_bencode)](https://docs.rs/serde_bencode)

A [Serde](https://github.com/serde-rs/serde) backed [Bencode](https://en.wikipedia.org/wiki/Bencode)
encoding/decoding library for Rust.

Forked from: <https://github.com/toby/serde-bencode> due to inactivity in upstream repo.

## Installation

Add the following to your `Cargo.toml`:
Expand Down
4 changes: 2 additions & 2 deletions benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ extern crate test;
extern crate serde_derive;

use serde::Serialize;
use serde_bencode::de::from_bytes;
use serde_bencode::ser::Serializer;
use test::Bencher;
use torrust_serde_bencode::de::from_bytes;
use torrust_serde_bencode::ser::Serializer;

#[bench]
fn ser_de_simple(b: &mut Bencher) {
Expand Down
2 changes: 1 addition & 1 deletion examples/parse_torrent.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[macro_use]
extern crate serde_derive;

use serde_bencode::de;
use serde_bytes::ByteBuf;
use std::io::{self, Read};
use torrust_serde_bencode::de;

#[derive(Debug, Deserialize)]
struct Node(String, i64);
Expand Down
4 changes: 2 additions & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "torrust_serde_bencode_fuzz"
name = "serde_bencode_fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
Expand All @@ -11,7 +11,7 @@ cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"

[dependencies.torrust_serde_bencode]
[dependencies.serde_bencode]
path = ".."

# Prevent this from interfering with workspaces
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/from_bytes.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

use torrust_serde_bencode::from_bytes;
use torrust_serde_bencode::value::Value;
use serde_bencode::from_bytes;
use serde_bencode::value::Value;

fuzz_target!(|data: &[u8]| {
let _: Result<Value, _> = from_bytes(data);
Expand Down
8 changes: 4 additions & 4 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl<'de, 'a, R: Read> de::Deserializer<'de> for &'a mut Deserializer<R> {
///
/// # Examples
/// ```
/// # fn main() -> Result<(), torrust_serde_bencode::Error> {
/// # fn main() -> Result<(), serde_bencode::Error> {
/// use serde_derive::{Serialize, Deserialize};
///
/// #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
Expand All @@ -355,7 +355,7 @@ impl<'de, 'a, R: Read> de::Deserializer<'de> for &'a mut Deserializer<R> {
/// }
///
/// let encoded = "d4:city18:Duckburg, Calisota6:street17:1313 Webfoot Walke".to_string();
/// let decoded: Address = torrust_serde_bencode::from_str(&encoded)?;
/// let decoded: Address = serde_bencode::from_str(&encoded)?;
///
/// assert_eq!(
/// decoded,
Expand Down Expand Up @@ -384,7 +384,7 @@ where
///
/// # Examples
/// ```
/// # fn main() -> Result<(), torrust_serde_bencode::Error> {
/// # fn main() -> Result<(), serde_bencode::Error> {
/// use serde_derive::{Serialize, Deserialize};
///
/// #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
Expand All @@ -394,7 +394,7 @@ where
/// }
///
/// let encoded = "d4:city18:Duckburg, Calisota6:street17:1313 Webfoot Walke".as_bytes();
/// let decoded: Address = torrust_serde_bencode::from_bytes(&encoded)?;
/// let decoded: Address = serde_bencode::from_bytes(&encoded)?;
///
/// assert_eq!(
/// decoded,
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fmt::Display;
use std::io::Error as IoError;
use std::result::Result as StdResult;

/// Alias for `Result<T, torrust_serde_bencode::Error>`.
/// Alias for `Result<T, serde_bencode::Error>`.
pub type Result<T> = StdResult<T, Error>;

/// Represents all possible errors which can occur when serializing or deserializing bencode.
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
//! price: 130,
//! };
//!
//! let serialized = torrust_serde_bencode::to_string(&apple)?;
//! let serialized = serde_bencode::to_string(&apple)?;
//!
//! // cspell:disable-next-line
//! assert_eq!(serialized, "d4:name5:Apple5:pricei130ee".to_string());
//!
//! let deserialized: Product = torrust_serde_bencode::from_str(&serialized)?;
//! let deserialized: Product = serde_bencode::from_str(&serialized)?;
//!
//! assert_eq!(
//! deserialized,
Expand Down
8 changes: 4 additions & 4 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl<'a> ser::Serializer for &'a mut Serializer {
///
/// # Examples
/// ```
/// # fn main() -> Result<(), torrust_serde_bencode::Error> {
/// # fn main() -> Result<(), serde_bencode::Error> {
/// use serde_derive::{Serialize, Deserialize};
///
/// #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
Expand All @@ -365,7 +365,7 @@ impl<'a> ser::Serializer for &'a mut Serializer {
/// city: "Duckburg, Calisota".to_string(),
/// };
///
/// let bytes = torrust_serde_bencode::to_bytes(&address)?;
/// let bytes = serde_bencode::to_bytes(&address)?;
/// assert_eq!(
/// String::from_utf8(bytes).unwrap(),
/// "d4:city18:Duckburg, Calisota6:street17:1313 Webfoot Walke",
Expand All @@ -388,7 +388,7 @@ pub fn to_bytes<T: ser::Serialize>(b: &T) -> Result<Vec<u8>> {
///
/// # Examples
/// ```
/// # fn main() -> Result<(), torrust_serde_bencode::Error> {
/// # fn main() -> Result<(), serde_bencode::Error> {
/// use serde_derive::{Serialize, Deserialize};
///
/// #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
Expand All @@ -403,7 +403,7 @@ pub fn to_bytes<T: ser::Serialize>(b: &T) -> Result<Vec<u8>> {
/// };
///
/// assert_eq!(
/// torrust_serde_bencode::to_string(&address)?,
/// serde_bencode::to_string(&address)?,
/// "d4:city18:Duckburg, Calisota6:street17:1313 Webfoot Walke".to_string(),
/// );
/// # Ok(())
Expand Down
12 changes: 6 additions & 6 deletions tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_bencode::de::{from_bytes, from_str};
use serde_bencode::error::Result;
use serde_bencode::ser::{to_bytes, to_string, Serializer};
use serde_bencode::value::Value;
use serde_derive::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::Debug;
use torrust_serde_bencode::de::{from_bytes, from_str};
use torrust_serde_bencode::error::Result;
use torrust_serde_bencode::ser::{to_bytes, to_string, Serializer};
use torrust_serde_bencode::value::Value;

fn test_value_ser_de<T: Into<Value>>(a: T) {
// Serialize
Expand Down Expand Up @@ -617,13 +617,13 @@ fn deserialize_too_long_byte_string() {
}

mod torrent_file {
use serde_bencode::de::{self, from_str};
use serde_bencode::ser::to_string;
use serde_bytes::ByteBuf;
use serde_derive::{Deserialize, Serialize};
use std::fmt::Debug;
use std::fs;
use std::io::Read;
use torrust_serde_bencode::de::{self, from_str};
use torrust_serde_bencode::ser::to_string;

#[test]
fn serialization() {
Expand Down

0 comments on commit f58baf7

Please sign in to comment.