pub fn from_encrypted(
        shared_secret: &[u8],
        ciphertext: BytesMut,
    ) -> Result<Self, StreamPacketError> {
        // TODO handle decryption failure
        let decrypted =
            decrypt(shared_secret, ciphertext).map_err(|_| StreamPacketError::FailedToDecrypt)?;
        StreamPacket::from_bytes_unencrypted(decrypted)
    }
/// Constructs a [Stream Packet](./struct.StreamPacket.html) from an encrypted buffer
/// and a shared secret
///
/// # Errors
/// 1. If the version of Stream Protocol doesn't match the hardcoded [stream version](constant.STREAM_VERSION.html)
/// 1. If the decryption fails
/// 1. If the decrypted bytes cannot be parsed to an unencrypted [Stream Packet](./struct.StreamPacket.html)
Constructs a [Stream Packet](./struct.StreamPacket.html) from an encrypted buffer
and a shared secret
Constructs a [ Stream Packet ] ( . / struct . StreamPacket . html ) from an encrypted buffer and a shared secret
pub fn from_encrypted(
        shared_secret: &[u8],
        ciphertext: BytesMut,
    ) -> Result<Self, StreamPacketError> {
        // TODO handle decryption failure
        let decrypted =
            decrypt(shared_secret, ciphertext).map_err(|_| StreamPacketError::FailedToDecrypt)?;
        StreamPacket::from_bytes_unencrypted(decrypted)
    }
pub fn from_encrypted ( shared_secret : & [ u8 ] , ciphertext : BytesMut , ) -> Result < Self , StreamPacketError > { // TODO handle decryption failure let decrypted = decrypt ( shared_secret , ciphertext ) . map_err ( | _ | StreamPacketError :: FailedToDecrypt ) ? ; StreamPacket :: from_bytes_unencrypted ( decrypted ) }
Constructs a [Stream Packet](./struct.StreamPacket.html) from an encrypted buffer
and a shared secret
Constructs a [ Stream Packet ] ( . / struct . StreamPacket . html ) from an encrypted buffer and a shared secret
shared_secret
&[u8]
ciphertext
BytesMut
shared_secret
&[u8]
ciphertext
BytesMut
errors
1. If the version of Stream Protocol doesn't match the hardcoded [stream version](constant.STREAM_VERSION.html)
1. If the decryption fails
1. If the decrypted bytes cannot be parsed to an unencrypted [Stream Packet](./struct.StreamPacket.html)
1 . If the version of Stream Protocol doesn ' t match the hardcoded [ stream version ] ( constant . STREAM_VERSION . html ) 1 . If the decryption fails 1 . If the decrypted bytes cannot be parsed to an unencrypted [ Stream Packet ] ( . / struct . StreamPacket . html )