diff -Nru rust-asynchronous-codec-0.6.2/.cargo_vcs_info.json rust-asynchronous-codec-0.7.0/.cargo_vcs_info.json --- rust-asynchronous-codec-0.6.2/.cargo_vcs_info.json 1970-01-01 00:00:01.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/.cargo_vcs_info.json 1970-01-01 00:00:01.000000000 +0000 @@ -1,6 +1,6 @@ { "git": { - "sha1": "d7ca166a25729992e1e760ff78579853a74b2eb8" + "sha1": "c818a83906891caf8aadcae8f899727c2c8393a8" }, "path_in_vcs": "" } \ No newline at end of file diff -Nru rust-asynchronous-codec-0.6.2/CHANGELOG.md rust-asynchronous-codec-0.7.0/CHANGELOG.md --- rust-asynchronous-codec-0.6.2/CHANGELOG.md 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/CHANGELOG.md 2006-07-24 01:21:28.000000000 +0000 @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.0] + +### Changed + +- Use GATs for `Encoder` trait to allow encoding of borrowed data. + See [PR 9](https://github.com/mxinden/asynchronous-codec/pull/9). + ## [0.6.2] ### Fixed diff -Nru rust-asynchronous-codec-0.6.2/Cargo.toml rust-asynchronous-codec-0.7.0/Cargo.toml --- rust-asynchronous-codec-0.6.2/Cargo.toml 1970-01-01 00:00:01.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/Cargo.toml 1970-01-01 00:00:01.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "asynchronous-codec" -version = "0.6.2" +version = "0.7.0" authors = ["Max Inden "] description = "Utilities for encoding and decoding frames using `async/await`" homepage = "https://github.com/mxinden/asynchronous-codec" diff -Nru rust-asynchronous-codec-0.6.2/Cargo.toml.orig rust-asynchronous-codec-0.7.0/Cargo.toml.orig --- rust-asynchronous-codec-0.6.2/Cargo.toml.orig 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/Cargo.toml.orig 2006-07-24 01:21:28.000000000 +0000 @@ -1,7 +1,7 @@ [package] name = "asynchronous-codec" edition = "2018" -version = "0.6.2" +version = "0.7.0" authors = ["Max Inden "] description = "Utilities for encoding and decoding frames using `async/await`" license = "MIT" diff -Nru rust-asynchronous-codec-0.6.2/debian/cargo-checksum.json rust-asynchronous-codec-0.7.0/debian/cargo-checksum.json --- rust-asynchronous-codec-0.6.2/debian/cargo-checksum.json 2023-08-20 11:09:12.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/debian/cargo-checksum.json 2023-11-23 15:39:17.000000000 +0000 @@ -1 +1 @@ -{"package":"4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568","files":{}} +{"package":"a860072022177f903e59730004fb5dc13db9275b79bb2aef7ba8ce831956c233","files":{}} diff -Nru rust-asynchronous-codec-0.6.2/debian/changelog rust-asynchronous-codec-0.7.0/debian/changelog --- rust-asynchronous-codec-0.6.2/debian/changelog 2023-08-20 11:09:12.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/debian/changelog 2023-11-23 15:39:17.000000000 +0000 @@ -1,3 +1,11 @@ +rust-asynchronous-codec (0.7.0-1) unstable; urgency=medium + + * Team upload. + * Package asynchronous-codec 0.7.0 from crates.io using debcargo 2.6.1 + + Closes: #1056261 + + -- James McCoy Thu, 23 Nov 2023 10:39:17 -0500 + rust-asynchronous-codec (0.6.2-1) unstable; urgency=medium * Package asynchronous-codec 0.6.2 from crates.io using debcargo 2.6.0 diff -Nru rust-asynchronous-codec-0.6.2/debian/control rust-asynchronous-codec-0.7.0/debian/control --- rust-asynchronous-codec-0.6.2/debian/control 2023-08-20 11:09:12.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/debian/control 2023-11-23 15:39:17.000000000 +0000 @@ -15,7 +15,7 @@ Maintainer: Debian Rust Maintainers Uploaders: Alexander Kjäll -Standards-Version: 4.6.1 +Standards-Version: 4.6.2 Vcs-Git: https://salsa.debian.org/rust-team/debcargo-conf.git [src/asynchronous-codec] Vcs-Browser: https://salsa.debian.org/rust-team/debcargo-conf/tree/master/src/asynchronous-codec Homepage: https://github.com/mxinden/asynchronous-codec @@ -51,20 +51,19 @@ librust-asynchronous-codec-0+serde-dev (= ${binary:Version}), librust-asynchronous-codec-0+serde-cbor-dev (= ${binary:Version}), librust-asynchronous-codec-0+serde-json-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6+cbor-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6+default-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6+json-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6+serde-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6+serde-cbor-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6+serde-json-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2+cbor-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2+default-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2+json-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2+serde-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2+serde-cbor-dev (= ${binary:Version}), - librust-asynchronous-codec-0.6.2+serde-json-dev (= ${binary:Version}) + librust-asynchronous-codec-0.7-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7+cbor-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7+default-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7+json-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7+serde-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7+serde-cbor-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7+serde-json-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0+cbor-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0+default-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0+json-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0+serde-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0+serde-cbor-dev (= ${binary:Version}), + librust-asynchronous-codec-0.7.0+serde-json-dev (= ${binary:Version}) Description: Utilities for encoding and decoding frames using `async/await` - Rust source code - This package contains the source for the Rust asynchronous-codec crate, - packaged by debcargo for use with cargo and dh-cargo. + Source code for Debianized Rust crate "asynchronous-codec" diff -Nru rust-asynchronous-codec-0.6.2/debian/tests/control rust-asynchronous-codec-0.7.0/debian/tests/control --- rust-asynchronous-codec-0.6.2/debian/tests/control 2023-08-20 11:09:12.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/debian/tests/control 2023-11-23 15:39:17.000000000 +0000 @@ -1,39 +1,39 @@ -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --all-features +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --all-features Features: test-name=rust-asynchronous-codec:@ Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --no-default-features --features cbor +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --no-default-features --features cbor Features: test-name=librust-asynchronous-codec-dev:cbor Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets Features: test-name=librust-asynchronous-codec-dev:default Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --no-default-features --features json +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --no-default-features --features json Features: test-name=librust-asynchronous-codec-dev:json Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --no-default-features --features serde +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --no-default-features --features serde Features: test-name=librust-asynchronous-codec-dev:serde Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --no-default-features --features serde_cbor +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --no-default-features --features serde_cbor Features: test-name=librust-asynchronous-codec-dev:serde_cbor Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --no-default-features --features serde_json +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --no-default-features --features serde_json Features: test-name=librust-asynchronous-codec-dev:serde_json Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.6.2 --all-targets --no-default-features +Test-Command: /usr/share/cargo/bin/cargo-auto-test asynchronous-codec 0.7.0 --all-targets --no-default-features Features: test-name=librust-asynchronous-codec-dev: Depends: dh-cargo (>= 18), librust-futures-0.3+default-dev, @ Restrictions: allow-stderr, skip-not-installable diff -Nru rust-asynchronous-codec-0.6.2/src/codec/bytes.rs rust-asynchronous-codec-0.7.0/src/codec/bytes.rs --- rust-asynchronous-codec-0.6.2/src/codec/bytes.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/codec/bytes.rs 2006-07-24 01:21:28.000000000 +0000 @@ -29,10 +29,10 @@ pub struct BytesCodec; impl Encoder for BytesCodec { - type Item = Bytes; + type Item<'a> = Bytes; type Error = Error; - fn encode(&mut self, src: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, src: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> { dst.extend_from_slice(&src); Ok(()) } diff -Nru rust-asynchronous-codec-0.6.2/src/codec/cbor.rs rust-asynchronous-codec-0.7.0/src/codec/cbor.rs --- rust-asynchronous-codec-0.6.2/src/codec/cbor.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/codec/cbor.rs 2006-07-24 01:21:28.000000000 +0000 @@ -141,10 +141,10 @@ for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static, { - type Item = Enc; + type Item<'a> = Enc; type Error = CborCodecError; - fn encode(&mut self, data: Self::Item, buf: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, data: Self::Item<'_>, buf: &mut BytesMut) -> Result<(), Self::Error> { // Encode cbor let j = serde_cbor::to_vec(&data)?; diff -Nru rust-asynchronous-codec-0.6.2/src/codec/json.rs rust-asynchronous-codec-0.7.0/src/codec/json.rs --- rust-asynchronous-codec-0.6.2/src/codec/json.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/codec/json.rs 2006-07-24 01:21:28.000000000 +0000 @@ -138,10 +138,10 @@ for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static, { - type Item = Enc; + type Item<'a> = Enc; type Error = JsonCodecError; - fn encode(&mut self, data: Self::Item, buf: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, data: Self::Item<'_>, buf: &mut BytesMut) -> Result<(), Self::Error> { // Encode json let j = serde_json::to_string(&data)?; diff -Nru rust-asynchronous-codec-0.6.2/src/codec/length.rs rust-asynchronous-codec-0.7.0/src/codec/length.rs --- rust-asynchronous-codec-0.6.2/src/codec/length.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/codec/length.rs 2006-07-24 01:21:28.000000000 +0000 @@ -18,10 +18,10 @@ /// pub struct MyStringCodec(LengthCodec); /// /// impl Encoder for MyStringCodec { -/// type Item = String; +/// type Item<'a> = String; /// type Error = Error; /// -/// fn encode(&mut self, src: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { +/// fn encode(&mut self, src: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> { /// let bytes = Bytes::from(src); /// self.0.encode(bytes, dst) /// } @@ -47,10 +47,10 @@ pub struct LengthCodec; impl Encoder for LengthCodec { - type Item = Bytes; + type Item<'a> = Bytes; type Error = Error; - fn encode(&mut self, src: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, src: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> { dst.reserve(U64_LENGTH + src.len()); dst.put_u64(src.len() as u64); dst.extend_from_slice(&src); diff -Nru rust-asynchronous-codec-0.6.2/src/codec/lines.rs rust-asynchronous-codec-0.7.0/src/codec/lines.rs --- rust-asynchronous-codec-0.6.2/src/codec/lines.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/codec/lines.rs 2006-07-24 01:21:28.000000000 +0000 @@ -21,10 +21,10 @@ pub struct LinesCodec; impl Encoder for LinesCodec { - type Item = String; + type Item<'a> = String; type Error = Error; - fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, item: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> { dst.reserve(item.len()); dst.put(item.as_bytes()); Ok(()) diff -Nru rust-asynchronous-codec-0.6.2/src/encoder.rs rust-asynchronous-codec-0.7.0/src/encoder.rs --- rust-asynchronous-codec-0.6.2/src/encoder.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/encoder.rs 2006-07-24 01:21:28.000000000 +0000 @@ -5,19 +5,50 @@ /// Encoding of messages as bytes, for use with `FramedWrite`. pub trait Encoder { /// The type of items consumed by `encode` - type Item; + type Item<'a>; /// The type of encoding errors. type Error: From; /// Encodes an item into the `BytesMut` provided by dst. - fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error>; + fn encode(&mut self, item: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error>; } impl Encoder for Fuse { - type Item = U::Item; + type Item<'a> = U::Item<'a>; type Error = U::Error; - fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, item: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> { self.u.encode(item, dst) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::FramedWrite; + use futures::executor::block_on; + use futures_util::SinkExt; + + #[test] + fn can_use_borrowed_data() { + let mut buf = Vec::new(); + + let mut write = FramedWrite::new(&mut buf, BorrowedCodec); + block_on(write.send(&[1, 2, 3, 4])).unwrap(); + + assert_eq!(buf, vec![1, 2, 3, 4]) + } + + struct BorrowedCodec; + + impl Encoder for BorrowedCodec { + type Item<'a> = &'a [u8]; + type Error = Error; + + fn encode(&mut self, item: Self::Item<'_>, dst: &mut BytesMut) -> Result<(), Self::Error> { + dst.extend_from_slice(item); + + Ok(()) + } + } +} diff -Nru rust-asynchronous-codec-0.6.2/src/framed.rs rust-asynchronous-codec-0.7.0/src/framed.rs --- rust-asynchronous-codec-0.6.2/src/framed.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/framed.rs 2006-07-24 01:21:28.000000000 +0000 @@ -163,7 +163,7 @@ } } -impl Sink for Framed +impl Sink> for Framed where T: AsyncWrite + Unpin, U: Encoder, @@ -173,7 +173,7 @@ fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { self.project().inner.poll_ready(cx) } - fn start_send(self: Pin<&mut Self>, item: U::Item) -> Result<(), Self::Error> { + fn start_send(self: Pin<&mut Self>, item: U::Item<'_>) -> Result<(), Self::Error> { self.project().inner.start_send(item) } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { @@ -204,7 +204,6 @@ /// Changes the codec used in this `FramedParts`. pub fn map_codec(self, f: F) -> FramedParts where - V: Encoder + Decoder, F: FnOnce(U) -> V, { FramedParts { diff -Nru rust-asynchronous-codec-0.6.2/src/framed_write.rs rust-asynchronous-codec-0.7.0/src/framed_write.rs --- rust-asynchronous-codec-0.6.2/src/framed_write.rs 2006-07-24 01:21:28.000000000 +0000 +++ rust-asynchronous-codec-0.7.0/src/framed_write.rs 2006-07-24 01:21:28.000000000 +0000 @@ -140,7 +140,7 @@ } } -impl Sink for FramedWrite +impl Sink> for FramedWrite where T: AsyncWrite + Unpin, E: Encoder, @@ -150,7 +150,7 @@ fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { self.project().inner.poll_ready(cx) } - fn start_send(self: Pin<&mut Self>, item: E::Item) -> Result<(), Self::Error> { + fn start_send(self: Pin<&mut Self>, item: E::Item<'_>) -> Result<(), Self::Error> { self.project().inner.start_send(item) } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { @@ -221,7 +221,7 @@ } } -impl Sink for FramedWrite2 +impl Sink> for FramedWrite2 where T: AsyncWrite + Encoder + Unpin, { @@ -241,7 +241,7 @@ Poll::Ready(Ok(())) } - fn start_send(mut self: Pin<&mut Self>, item: T::Item) -> Result<(), Self::Error> { + fn start_send(mut self: Pin<&mut Self>, item: T::Item<'_>) -> Result<(), Self::Error> { let this = &mut *self; this.inner.encode(item, &mut this.buffer) }