pub struct EncodedMessage<P> {
pub typ: ContentType,
pub version: ProtocolVersion,
pub payload: P,
}Expand description
A TLS message with encoded (but not necessarily encrypted) payload.
Fields§
§typ: ContentTypeThe content type of this message.
version: ProtocolVersionThe protocol version of this message.
payload: PThe payload of this message.
Implementations§
Source§impl<P> EncodedMessage<P>
impl<P> EncodedMessage<P>
Sourcepub fn new(typ: ContentType, version: ProtocolVersion, payload: P) -> Self
pub fn new(typ: ContentType, version: ProtocolVersion, payload: P) -> Self
Create a new EncodedMessage with the given fields.
Source§impl<'a> EncodedMessage<Payload<'a>>
impl<'a> EncodedMessage<Payload<'a>>
Sourcepub fn read(r: &mut Reader<'a>) -> Result<Self, MessageError>
pub fn read(r: &mut Reader<'a>) -> Result<Self, MessageError>
Construct by decoding from a [Reader].
MessageError allows callers to distinguish between valid prefixes (might
become valid if we read more data) and invalid data.
Sourcepub fn into_unencrypted_opaque(self) -> EncodedMessage<OutboundOpaque>
pub fn into_unencrypted_opaque(self) -> EncodedMessage<OutboundOpaque>
Convert into an unencrypted EncodedMessage<OutboundOpaque> (without decrypting).
Sourcepub fn borrow_outbound(&'a self) -> EncodedMessage<OutboundPlain<'a>>
pub fn borrow_outbound(&'a self) -> EncodedMessage<OutboundPlain<'a>>
Borrow as an EncodedMessage<OutboundPlain<'a>>.
Sourcepub fn into_owned(self) -> Self
pub fn into_owned(self) -> Self
Convert into an owned EncodedMessage<Plain<'static>>.
Source§impl<'a> EncodedMessage<InboundOpaque<'a>>
impl<'a> EncodedMessage<InboundOpaque<'a>>
Sourcepub fn into_tls13_unpadded_message(
self,
) -> Result<EncodedMessage<&'a [u8]>, Error>
pub fn into_tls13_unpadded_message( self, ) -> Result<EncodedMessage<&'a [u8]>, Error>
For TLS1.3 (only), checks the length msg.payload is valid and removes the padding.
Returns an error if the message (pre-unpadding) is too long, or the padding is invalid, or the message (post-unpadding) is too long.
Sourcepub fn into_plain_message_range(
self,
range: Range<usize>,
) -> EncodedMessage<&'a [u8]>
pub fn into_plain_message_range( self, range: Range<usize>, ) -> EncodedMessage<&'a [u8]>
Force conversion into a plaintext message.
range restricts the resulting message: this function panics if it is out of range for
the underlying message payload.
This should only be used for messages that are known to be in plaintext. Otherwise, the
EncodedMessage<InboundOpaque<'_>> should be decrypted into an
EncodedMessage<&'_ [u8]> using a MessageDecrypter.
Sourcepub fn into_plain_message(self) -> EncodedMessage<&'a [u8]>
pub fn into_plain_message(self) -> EncodedMessage<&'a [u8]>
Force conversion into a plaintext message.
This should only be used for messages that are known to be in plaintext. Otherwise, the
EncodedMessage<InboundOpaque<'a>> should be decrypted into a
EncodedMessage<&'a [u8]> using a MessageDecrypter.
Trait Implementations§
Source§impl<P: Clone> Clone for EncodedMessage<P>
impl<P: Clone> Clone for EncodedMessage<P>
Source§fn clone(&self) -> EncodedMessage<P>
fn clone(&self) -> EncodedMessage<P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more