Skip to content

Commit

Permalink
Added separate readme for crates.io package
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Dec 31, 2021
2 parents 3afa385 + 339f9c9 commit 347a1d9
Show file tree
Hide file tree
Showing 31 changed files with 266 additions and 115 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.1.0-dev.2

### Breaking Changes

- Split serialization and deserialization into separate traits, and built a path
for borrowed deserialization.

## v0.1.0-dev.1

- First release.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ members = ["crates/*", "examples/*", "xtask"]

# [patch.crates-io]
# pot = { path = "../pot/pot" }

# [patch."https://github.com/khonsulabs/khonsu-tools.git"]
# khonsu-tools = { path = "../khonsu-tools/khonsu-tools" }

# [patch."https://github.com/khonsulabs/rustme.git"]
# rustme = { path = "../rustme" }
3 changes: 1 addition & 2 deletions crates/transmog-async/.rustme/async-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ This crate has been adapted from
[`async-bincode`](https://github.com/jonhoo/async-bincode) to generically
support the [`Format`][format] trait.


[format]: $format$
[format]: $format$
8 changes: 4 additions & 4 deletions crates/transmog-async/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "transmog-async"
version = "0.1.0-dev.1"
version = "0.1.0-dev.2"
edition = "2021"
description = "Async stream support for Transmog"
repository = "https://github.com/khonsulabs/transmog"
Expand All @@ -10,7 +10,7 @@ categories = ["encoding"]
readme = "./README.md"

[dependencies]
transmog = { path = "../transmog", version = "0.1.0-dev.1" }
transmog = { path = "../transmog", version = "0.1.0-dev.2" }
futures-core = { version = "0.3" }
futures-sink = { version = "0.3" }
tokio = { version = "1.0", features = ["net"] }
Expand All @@ -22,5 +22,5 @@ thiserror = "1"
anyhow = "1"
futures = "0.3"
tokio = { version = "1.0", features = ["full"] }
transmog-bincode = { path = "../transmog-bincode", version = "0.1.0-dev.1" }
transmog-pot = { path = "../transmog-pot", version = "0.1.0-dev.1" }
transmog-bincode = { path = "../transmog-bincode", version = "0.1.0-dev.2" }
transmog-pot = { path = "../transmog-pot", version = "0.1.0-dev.2" }
2 changes: 1 addition & 1 deletion crates/transmog-async/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ This crate has been adapted from
[`async-bincode`](https://github.com/jonhoo/async-bincode) to generically
support the [`Format`][format] trait.


[format]: https://docs.rs/transmog/*/transmog/trait.Format.html

## Open-source Licenses

This project, like all projects from [Khonsu Labs](https://khonsulabs.com/), are
Expand Down
3 changes: 1 addition & 2 deletions crates/transmog-async/src/.crate-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ This crate has been adapted from
[`async-bincode`](https://github.com/jonhoo/async-bincode) to generically
support the [`Format`][format] trait.


[format]: crate::transmog::Format
[format]: crate::transmog::Format
13 changes: 7 additions & 6 deletions crates/transmog-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<TStream, TFormat> Builder<(), (), TStream, TFormat> {
/// Sets `T` as the type for both sending and receiving.
pub fn sends_and_receives<T>(self) -> Builder<T, T, TStream, TFormat>
where
TFormat: Format<T>,
TFormat: Format<'static, T>,
{
Builder {
stream: self.stream,
Expand All @@ -72,7 +72,7 @@ impl<TReads, TStream, TFormat> Builder<TReads, (), TStream, TFormat> {
/// Sets `T` as the type of data that is written to this stream.
pub fn sends<T>(self) -> Builder<TReads, T, TStream, TFormat>
where
TFormat: Format<T>,
TFormat: Format<'static, T>,
{
Builder {
stream: self.stream,
Expand All @@ -86,7 +86,7 @@ impl<TWrites, TStream, TFormat> Builder<(), TWrites, TStream, TFormat> {
/// Sets `T` as the type of data that is read from this stream.
pub fn receives<T>(self) -> Builder<T, TWrites, TStream, TFormat>
where
TFormat: Format<T>,
TFormat: Format<'static, T>,
{
Builder {
stream: self.stream,
Expand Down Expand Up @@ -319,7 +319,7 @@ where
TReads,
TFormat,
>: Stream<Item = Result<TReads, TFormat::Error>>,
TFormat: Format<TWrites>,
TFormat: Format<'static, TWrites>,
{
type Item = Result<TReads, TFormat::Error>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand All @@ -332,7 +332,7 @@ impl<TReads, TWrites, TStream, TDestination, TFormat> Sink<TWrites>
where
TStream: Unpin,
TransmogWriter<TStream, TWrites, TDestination, TFormat>: Sink<TWrites, Error = TFormat::Error>,
TFormat: Format<TWrites>,
TFormat: Format<'static, TWrites>,
{
type Error = TFormat::Error;

Expand All @@ -356,14 +356,15 @@ where
#[cfg(test)]
mod tests {
use futures::prelude::*;
use transmog::OwnedDeserializer;
use transmog_bincode::Bincode;
use transmog_pot::Pot;

use super::*;

async fn it_works<
T: std::fmt::Debug + Clone + PartialEq + Send,
TFormat: Format<T> + Clone + 'static,
TFormat: Format<'static, T> + OwnedDeserializer<T> + Clone + 'static,
>(
format: TFormat,
values: &[T],
Expand Down
6 changes: 3 additions & 3 deletions crates/transmog-async/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bytes::{Buf, BytesMut};
use futures_core::{ready, Stream};
use ordered_varint::Variable;
use tokio::io::{AsyncRead, ReadBuf};
use transmog::Format;
use transmog::OwnedDeserializer;

/// A wrapper around an asynchronous reader that produces an asynchronous stream
/// of Transmog-decoded values.
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<R, T, F> TransmogReader<R, T, F> {
impl<R, T, F> Stream for TransmogReader<R, T, F>
where
R: AsyncRead + Unpin,
F: Format<T>,
F: OwnedDeserializer<T>,
{
type Item = Result<T, F::Error>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand All @@ -106,7 +106,7 @@ where
if self.buffer.len() >= target_buffer_size {
let message = self
.format
.deserialize(&self.buffer[header_len..target_buffer_size])
.deserialize_owned(&self.buffer[header_len..target_buffer_size])
.unwrap();
self.buffer.advance(target_buffer_size);
break Poll::Ready(Some(Ok(message)));
Expand Down
8 changes: 4 additions & 4 deletions crates/transmog-async/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ pub struct SyncDestination;
#[doc(hidden)]
pub trait TransmogWriterFor<T, F>
where
F: Format<T>,
F: Format<'static, T>,
{
fn append(&mut self, item: &T) -> Result<(), F::Error>;
}

impl<W, T, F> TransmogWriterFor<T, F> for TransmogWriter<W, T, AsyncDestination, F>
where
F: Format<T>,
F: Format<'static, T>,
{
fn append(&mut self, item: &T) -> Result<(), F::Error> {
if let Some(serialized_length) = self.format.serialized_size(item)? {
Expand Down Expand Up @@ -164,7 +164,7 @@ fn usize_to_u64(value: usize) -> Result<u64, std::io::Error> {

impl<W, T, F> TransmogWriterFor<T, F> for TransmogWriter<W, T, SyncDestination, F>
where
F: Format<T>,
F: Format<'static, T>,
{
fn append(&mut self, item: &T) -> Result<(), F::Error> {
self.format.serialize_into(item, &mut self.buffer)
Expand All @@ -173,7 +173,7 @@ where

impl<W, T, D, F> Sink<T> for TransmogWriter<W, T, D, F>
where
F: Format<T>,
F: Format<'static, T>,
W: AsyncWrite + Unpin,
Self: TransmogWriterFor<T, F>,
{
Expand Down
8 changes: 4 additions & 4 deletions crates/transmog-bincode/.rustme/bincode-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
This crate provides a [`Format`][format] trait implementation using the [`Bincode`][bincode-type] type:

```rust
use transmog::Format;
use transmog::{Format, OwnedDeserializer};
use transmog_bincode::Bincode;

let bincode = Bincode::default();
let serialized = bincode.serialize(&42_u64).unwrap();
let deserialized: u64 = bincode.deserialize(&serialized).unwrap();
let deserialized: u64 = bincode.deserialize_owned(&serialized).unwrap();
assert_eq!(deserialized, 42);
```

Expand All @@ -22,12 +22,12 @@ If you're working with existing data that used the global
serialization/deserialization methods, use `Bincode::legacy_default()` instead:

```rust
use transmog::Format;
use transmog::{Format, OwnedDeserializer};
use transmog_bincode::Bincode;

let bincode = Bincode::legacy_default();
let serialized = bincode.serialize(&42_u64).unwrap();
let deserialized: u64 = bincode.deserialize(&serialized).unwrap();
let deserialized: u64 = bincode.deserialize_owned(&serialized).unwrap();
assert_eq!(deserialized, 42);
```

Expand Down
6 changes: 3 additions & 3 deletions crates/transmog-bincode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "transmog-bincode"
version = "0.1.0-dev.1"
version = "0.1.0-dev.2"
edition = "2021"
description = "Bincode adaptor for Transmog"
repository = "https://github.com/khonsulabs/transmog"
Expand All @@ -12,11 +12,11 @@ readme = "./README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
transmog = { path = "../transmog", version = "0.1.0-dev.1" }
transmog = { path = "../transmog", version = "0.1.0-dev.2" }
serde = "1.0.124"
bincode = "1"

[dev-dependencies]
transmog = { path = "../transmog", version = "0.1.0-dev.1", features = [
transmog = { path = "../transmog", version = "0.1.0-dev.2", features = [
"test-util",
] }
8 changes: 4 additions & 4 deletions crates/transmog-bincode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
This crate provides a [`Format`][format] trait implementation using the [`Bincode`][bincode-type] type:

```rust
use transmog::Format;
use transmog::{Format, OwnedDeserializer};
use transmog_bincode::Bincode;

let bincode = Bincode::default();
let serialized = bincode.serialize(&42_u64).unwrap();
let deserialized: u64 = bincode.deserialize(&serialized).unwrap();
let deserialized: u64 = bincode.deserialize_owned(&serialized).unwrap();
assert_eq!(deserialized, 42);
```

Expand All @@ -24,12 +24,12 @@ If you're working with existing data that used the global
serialization/deserialization methods, use `Bincode::legacy_default()` instead:

```rust
use transmog::Format;
use transmog::{Format, OwnedDeserializer};
use transmog_bincode::Bincode;

let bincode = Bincode::legacy_default();
let serialized = bincode.serialize(&42_u64).unwrap();
let deserialized: u64 = bincode.deserialize(&serialized).unwrap();
let deserialized: u64 = bincode.deserialize_owned(&serialized).unwrap();
assert_eq!(deserialized, 42);
```

Expand Down
8 changes: 4 additions & 4 deletions crates/transmog-bincode/src/.crate-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
This crate provides a [`Format`][format] trait implementation using the [`Bincode`][bincode-type] type:

```rust
use transmog::Format;
use transmog::{Format, OwnedDeserializer};
use transmog_bincode::Bincode;

let bincode = Bincode::default();
let serialized = bincode.serialize(&42_u64).unwrap();
let deserialized: u64 = bincode.deserialize(&serialized).unwrap();
let deserialized: u64 = bincode.deserialize_owned(&serialized).unwrap();
assert_eq!(deserialized, 42);
```

Expand All @@ -22,12 +22,12 @@ If you're working with existing data that used the global
serialization/deserialization methods, use `Bincode::legacy_default()` instead:

```rust
use transmog::Format;
use transmog::{Format, OwnedDeserializer};
use transmog_bincode::Bincode;

let bincode = Bincode::legacy_default();
let serialized = bincode.serialize(&42_u64).unwrap();
let deserialized: u64 = bincode.deserialize(&serialized).unwrap();
let deserialized: u64 = bincode.deserialize_owned(&serialized).unwrap();
assert_eq!(deserialized, 42);
```

Expand Down
Loading

0 comments on commit 347a1d9

Please sign in to comment.