https://github.com/synphonyte/codee
Easy and flexible way of encoding and decoding data into either strings or bytes.
https://github.com/synphonyte/codee
Last synced: 7 months ago
JSON representation
Easy and flexible way of encoding and decoding data into either strings or bytes.
- Host: GitHub
- URL: https://github.com/synphonyte/codee
- Owner: Synphonyte
- License: apache-2.0
- Created: 2024-07-06T23:45:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-08T21:33:58.000Z (8 months ago)
- Last Synced: 2025-10-10T13:15:54.381Z (8 months ago)
- Language: Rust
- Size: 51.8 KB
- Stars: 9
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Codee
[](https://crates.io/crates/codee)
[](https://docs.rs/codee/)
[](https://github.com/synphonyte/codee#license)
[](https://github.com/synphonyte/codee/actions/workflows/ci.yml)
Easy and flexible way of encoding and decoding data into either strings or bytes.
This crate provides generic traits for `Encoder`s and `Decoder`s as well as several
implementations for commonly used (de)serializer crates.
This makes it easily possible to abstract away the serialization and deserialization independent
of the concrete crate used. You can write a function like this:
```rust
use codee::{CodecError, Decoder, Encoder};
fn store_value(value: T) -> Result<(), CodecError<>::Error, >::Error>>
where
Codec: Encoder + Decoder,
{
let encoded = Codec::encode(&value).map_err(CodecError::Encode)?;
let decoded = Codec::decode(&encoded).map_err(CodecError::Decode)?;
Ok(())
}
// Then we can use it like this:
use codee::string::{JsonSerdeCodec, FromToStringCodec};
#[derive(serde::Serialize, serde::Deserialize)]
struct MyStruct {
field: usize,
}
store_value::(42);
store_value::(MyStruct { field: 42 });
```