Added `from_parts()`, as counterpart to `into_parts()`.

Fortune for chacha20stream's current commit: Half blessing − 半吉
master
Avril 3 years ago
parent 0645e61590
commit 903bfcd7c4
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,6 +1,6 @@
[package] [package]
name = "chacha20stream" name = "chacha20stream"
version = "2.1.0" version = "2.2.0"
keywords = ["chacha20_poly1305", "stream", "wrapper", "encryption", "decryption"] keywords = ["chacha20_poly1305", "stream", "wrapper", "encryption", "decryption"]
description = "A writable wrapper stream for encryption and decryption with the stream cipher chacha20_poly1305" description = "A writable wrapper stream for encryption and decryption with the stream cipher chacha20_poly1305"
homepage = "https://git.flanchan.moe/flanchan/chacha20stream" homepage = "https://git.flanchan.moe/flanchan/chacha20stream"

@ -144,6 +144,15 @@ where W: Write
{ {
(self.stream, self.crypter) (self.stream, self.crypter)
} }
/// Create a sink from a stream and a crypter
///
/// The counterpart to `into_parts()`.
#[inline] pub fn from_parts(stream: W, crypter: Crypter) -> Self
{
Self::new(stream, crypter)
}
} }

@ -242,6 +242,14 @@ where R: Read
{ {
(self.stream, self.crypter) (self.stream, self.crypter)
} }
/// Create a source from a stream and a crypter
///
/// The counterpart to `into_parts()`.
#[inline] pub fn from_parts(stream: R, crypter: Crypter) -> Self
{
Self::new(stream, crypter)
}
} }

@ -108,6 +108,16 @@ impl<W: AsyncWrite> Sink<W>
{ {
(self.stream, self.crypter) (self.stream, self.crypter)
} }
/// Create a sink from a stream and a crypter
///
/// The counterpart to `into_parts()`.
#[inline] pub fn from_parts(stream: W, crypter: Crypter) -> Self
{
Self {
stream, crypter
}
}
/// The crypter of this instance /// The crypter of this instance
#[inline] pub fn crypter(&self) -> &Crypter #[inline] pub fn crypter(&self) -> &Crypter

@ -74,6 +74,17 @@ impl<R: AsyncRead> Source<R>
(self.stream, self.crypter) (self.stream, self.crypter)
} }
/// Create a source from a stream and a crypter
///
/// The counterpart to `into_parts()`.
#[inline] pub fn from_parts(stream: R, crypter: Crypter) -> Self
{
Self {
stream, crypter
}
}
/// The crypter of this instance /// The crypter of this instance
#[inline] pub fn crypter(&self) -> &Crypter #[inline] pub fn crypter(&self) -> &Crypter
{ {

Loading…
Cancel
Save