From 162a9ebef0ab6f0e1ab93cc8c019dcdb804565d9 Mon Sep 17 00:00:00 2001 From: Flix Date: Sat, 28 Sep 2024 23:38:18 +0200 Subject: [PATCH] Rename crate --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 8 ++++---- README.md | 26 +++++++++++++------------- docs/format-specification.md | 12 ++++++------ examples/simple.rs | 4 ++-- src/lib.rs | 16 ++++++++-------- tests/all/json_data.rs | 6 +++--- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcb142a..dfa9570 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,18 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "brief" -version = "0.1.0" -dependencies = [ - "heapless", - "serde", - "serde_bytes", - "serde_json", - "tracing", - "tracing-subscriber", -] - [[package]] name = "byteorder" version = "1.5.0" @@ -193,6 +181,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-brief" +version = "0.1.0" +dependencies = [ + "heapless", + "serde", + "serde_bytes", + "serde_json", + "tracing", + "tracing-subscriber", +] + [[package]] name = "serde_bytes" version = "0.11.15" diff --git a/Cargo.toml b/Cargo.toml index d2ae180..2542fe1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,15 +2,15 @@ authors = ["Flix "] categories = ["encoding", "parser-implementations", "no-std", "no-std::no-alloc", "embedded"] description = "A brief, self-descriptive, serde-compatible binary format." -documentation = "https://docs.rs/brief" +documentation = "https://docs.rs/serde-brief" edition = "2021" exclude = ["/tests/data", "/.github"] -homepage = "https://github.com/FlixCoder/fhir-sdk" +homepage = "https://github.com/FlixCoder/serde-brief" keywords = ["serde", "encoding", "binary", "data", "no-std"] license = "MIT" -name = "brief" +name = "serde-brief" readme = "README.md" -repository = "https://github.com/FlixCoder/brief" +repository = "https://github.com/FlixCoder/serde-brief" rust-version = "1.81" version = "0.1.0" diff --git a/README.md b/README.md index 3e6e523..f9fbf27 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Brief +# Serde-Brief -[![crates.io page](https://img.shields.io/crates/v/brief.svg)](https://crates.io/crates/brief) -[![docs.rs page](https://docs.rs/brief/badge.svg)](https://docs.rs/brief/) -![license: MIT](https://img.shields.io/crates/l/brief.svg) +[![crates.io page](https://img.shields.io/crates/v/serde-brief.svg)](https://crates.io/crates/serde-brief) +[![docs.rs page](https://docs.rs/serde-brief/badge.svg)](https://docs.rs/serde-brief/) +![license: MIT](https://img.shields.io/crates/l/serde-brief.svg) -Brief (German for letter) is a crate for encoding and decoding data into a binary format that is self-descriptive and [serde](https://docs.rs/serde/)-compatible. +Serde-Brief (German for letter) is a crate for encoding and decoding data into a binary format that is self-descriptive and [serde](https://docs.rs/serde/)-compatible. ## Design Goals @@ -29,7 +29,7 @@ By default, structs' field names and enums' variant names are encoded as strings ## Comparisons -How does Brief compare to ..? +How does Serde-Brief compare to ..? ### [Postcard](https://docs.rs/postcard/) @@ -37,7 +37,7 @@ Postcard is NOT a self-describing format. It's encoding solely consists of the r Postcard is producing way smaller encoded data due to the missing schema information and field names. It is also faster. -Brief supports decoding unknown data and parsing it into the requested structures regardless of additional fields or different orders. +Serde-Brief supports decoding unknown data and parsing it into the requested structures regardless of additional fields or different orders. ### [Pot](https://docs.rs/pot/) @@ -45,19 +45,19 @@ Pot is a self-describing format as well. It's encoding is more space-efficient d It is also not no-std compatible. -Brief is faster most of the times, but less space-efficient. +Serde-Brief is faster most of the times, but less space-efficient. ### [Serde_json](https://docs.rs/serde_json/) JSON is a self-describing format as well. However, it is text based and therefore requires string escaping. Bytes cannot be efficiently represented. However, JSON is widely adopted, as you already know :D -In Brief, map keys can not only be strings. Unlike in JSON, keys can be nested data, so something like `HashMap` can be serialized and deserialized without issues. +In Serde-Brief, map keys can not only be strings. Unlike in JSON, keys can be nested data, so something like `HashMap` can be serialized and deserialized without issues. -Brief is both more space-efficient and faster. +Serde-Brief is both more space-efficient and faster. ## Usage -Add the library to your project with `cargo add brief`. By default, no features are enabled (currently), so it is no-std by default. You can enable use of `Vec`s and such with features like `alloc` or `std`. +Add the library to your project with `cargo add serde-brief`. By default, no features are enabled (currently), so it is no-std by default. You can enable use of `Vec`s and such with features like `alloc` or `std`. ### Example Serialization/Deserialization @@ -74,7 +74,7 @@ struct MyBorrowedData<'a> { } let data = MyBorrowedData { name: "Holla", age: 21 }; -let mut output: Vec = brief::to_heapless_vec(&data).unwrap(); +let mut output: Vec = serde_brief::to_heapless_vec(&data).unwrap(); assert_eq!(output, [ 17, @@ -83,7 +83,7 @@ assert_eq!(output, [ 18 ]); -let parsed: MyBorrowedData = brief::from_slice(&output).unwrap(); +let parsed: MyBorrowedData = serde_brief::from_slice(&output).unwrap(); assert_eq!(parsed, data); ``` diff --git a/docs/format-specification.md b/docs/format-specification.md index f7a6a99..3e8471a 100644 --- a/docs/format-specification.md +++ b/docs/format-specification.md @@ -1,4 +1,4 @@ -# Brief Binary Format +# Serde-Brief Binary Format The format is close to JSON, modified to be better, binary and fit to [serde's data model](https://serde.rs/data-model.html). @@ -23,8 +23,8 @@ The format includes information on the structure of the data. ## Defined Types -Every value in Brief is prepended with a byte detailing its type. -The Brief format currently contains these types: +Every value in Serde-Brief is prepended with a byte detailing its type. +The Serde-Brief format currently contains these types: | Type | Description | Byte value | | --- | --- | --- | @@ -91,7 +91,7 @@ Values can have any type, so even maps can consist of arbitrarily complex keys a ## Mapping of Rust Types to Encoded Data -The encoding/serialization and decoding/deserialization happens via `serde`, so it follows the [serde data model](https://serde.rs/data-model.html). Please familiarize yourself with its concept to fully understand the following. In any case, the following describes how Rust types are mapped to Brief format types. +The encoding/serialization and decoding/deserialization happens via `serde`, so it follows the [serde data model](https://serde.rs/data-model.html). Please familiarize yourself with its concept to fully understand the following. In any case, the following describes how Rust types are mapped to Serde-Brief format types. There are two modes of the format. The first and default encodes structs as maps with keys being strings of the fields' names. The second encodes structs as maps with keys being unsigned integers, where the value denotes the index/position in the struct. Similarly, the same happens for enums. Variants are encoded either as string or as unsigned integer denoting their index (NOT discriminant). @@ -107,7 +107,7 @@ Note that (at least currently) the deserializer can parse data regardless of whi - Smaller footprint: strings need more space in the encoding. -### Serde Datatypes in Brief (String Representation) +### Serde Datatypes in Serde-Brief (String Representation) The list of serde's types can be found [here](https://serde.rs/data-model.html), along with how Rust types are mapped to serde's types. @@ -135,7 +135,7 @@ The list of serde's types can be found [here](https://serde.rs/data-model.html), | tuple variant | MapStart, String, SeqStart .. SeqEnd, MapEnd | Enum names are not used. Variants with values are a map with a single key-value pair. The key is the variant name as string. The value is a sequence of the encoded values. | | struct variant | MapStart, String, MapStart .. MapEnd, MapEnd | Enum names are not used. Variants with values are a map with a single key-value pair. The key is the variant name as string. The value is a map of the field names to their values. | -### Serde Datatypes in Brief (Index Representation) +### Serde Datatypes in Serde-Brief (Index Representation) The list of serde's types can be found [here](https://serde.rs/data-model.html), along with how Rust types are mapped to serde's types. diff --git a/examples/simple.rs b/examples/simple.rs index ad46c79..ec3c17f 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -12,7 +12,7 @@ struct MyBorrowedData<'a> { fn main() { let data = MyBorrowedData { name: "Holla", age: 21 }; let mut output = [0; 22]; - let bytes = brief::to_slice(&data, &mut output).unwrap(); + let bytes = serde_brief::to_slice(&data, &mut output).unwrap(); assert_eq!( bytes, @@ -22,7 +22,7 @@ fn main() { ] ); - let parsed: MyBorrowedData = brief::from_slice(bytes).unwrap(); + let parsed: MyBorrowedData = serde_brief::from_slice(bytes).unwrap(); assert_eq!(parsed, data); } diff --git a/src/lib.rs b/src/lib.rs index 7cb3b4d..7965737 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ -//! # Brief +//! # Serde-Brief //! -//! Brief (German for letter) is a crate for encoding and decoding data into a binary format that is self-descriptive and [serde](https://docs.rs/serde/)-compatible. +//! Serde-Brief (German for letter) is a crate for encoding and decoding data into a binary format that is self-descriptive and [serde](https://docs.rs/serde/)-compatible. //! //! ## Design Goals //! @@ -39,9 +39,9 @@ //! //! ## Usage //! -//! Add the library to your project with `cargo add brief`. By default, no features are enabled -//! (currently), so it is no-std by default. You can enable use of `Vec`s and such with features -//! like `alloc` or `std`. +//! Add the library to your project with `cargo add serde-brief`. By default, no features are +//! enabled (currently), so it is no-std by default. You can enable use of `Vec`s and such with +//! features like `alloc` or `std`. //! //! ### Example Serialization/Deserialization //! @@ -59,7 +59,7 @@ //! } //! //! let data = MyBorrowedData { name: "Holla", age: 21 }; -//! let mut output: Vec = brief::to_heapless_vec(&data).unwrap(); +//! let mut output: Vec = serde_brief::to_heapless_vec(&data).unwrap(); //! //! assert_eq!( //! output, @@ -69,7 +69,7 @@ //! ] //! ); //! -//! let parsed: MyBorrowedData = brief::from_slice(&output).unwrap(); +//! let parsed: MyBorrowedData = serde_brief::from_slice(&output).unwrap(); //! assert_eq!(parsed, data); //! ``` #![cfg_attr(not(feature = "std"), no_std)] @@ -97,7 +97,7 @@ use ::std::io::{Read, Write}; pub use self::value::{from_value, from_value_with_config, to_value, to_value_with_config}; pub use self::{config::Config, de::Deserializer, error::Error, ser::Serializer}; -/// `Result` type that uses the `brief` error. +/// `Result` type that uses the `serde-brief` error. pub type Result = ::core::result::Result; /// Serialize a type into a slice of bytes using the given configuration. Returns the slice with the diff --git a/tests/all/json_data.rs b/tests/all/json_data.rs index 6d6165f..32a8587 100644 --- a/tests/all/json_data.rs +++ b/tests/all/json_data.rs @@ -1,11 +1,11 @@ //! Test with JSON blobs. #![cfg(feature = "std")] -use ::brief::value::Value; +use ::serde_brief::value::Value; fn roundtrip(value: Value<'_>) { - let bytes = brief::to_vec(&value).expect("serializing"); - let parsed: Value<'_> = brief::from_slice(&bytes).expect("deserializing"); + let bytes = serde_brief::to_vec(&value).expect("serializing"); + let parsed: Value<'_> = serde_brief::from_slice(&bytes).expect("deserializing"); assert_eq!(parsed, value); }