pub struct RecordLayer {
message_encrypter: Box<dyn MessageEncrypter>,
message_decrypter: Box<dyn MessageDecrypter>,
write_seq: u64,
read_seq: u64,
encrypt_state: DirectionState,
decrypt_state: DirectionState,
trial_decryption_len: Option<usize>,
}Fields§
§message_encrypter: Box<dyn MessageEncrypter>§message_decrypter: Box<dyn MessageDecrypter>§write_seq: u64§read_seq: u64§encrypt_state: DirectionState§decrypt_state: DirectionState§trial_decryption_len: Option<usize>Implementations§
Source§impl RecordLayer
impl RecordLayer
pub fn new() -> Self
pub fn is_encrypting(&self) -> bool
pub fn is_decrypting(&self) -> bool
pub fn doing_trial_decryption(&mut self, requested: usize) -> bool
Sourcepub fn prepare_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
pub fn prepare_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
Prepare to use the given MessageEncrypter for future message encryption.
It is not used until you call start_encrypting.
Sourcepub fn prepare_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
pub fn prepare_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
Prepare to use the given MessageDecrypter for future message decryption.
It is not used until you call start_decrypting.
Sourcepub fn start_encrypting(&mut self)
pub fn start_encrypting(&mut self)
Start using the MessageEncrypter previously provided to the previous
call to prepare_message_encrypter.
Sourcepub fn start_decrypting(&mut self)
pub fn start_decrypting(&mut self)
Start using the MessageDecrypter previously provided to the previous
call to prepare_message_decrypter.
Sourcepub fn set_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
pub fn set_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
Set and start using the given MessageEncrypter for future outgoing
message encryption.
Sourcepub fn set_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
pub fn set_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
Set and start using the given MessageDecrypter for future incoming
message decryption.
Sourcepub fn set_message_decrypter_with_trial_decryption(
&mut self,
cipher: Box<dyn MessageDecrypter>,
max_length: usize,
)
pub fn set_message_decrypter_with_trial_decryption( &mut self, cipher: Box<dyn MessageDecrypter>, max_length: usize, )
Set and start using the given MessageDecrypter for future incoming
message decryption, and enable “trial decryption” mode for when TLS1.3
0-RTT is attempted but rejected by the server.
pub fn finish_trial_decryption(&mut self)
Sourcepub fn wants_close_before_decrypt(&self) -> bool
pub fn wants_close_before_decrypt(&self) -> bool
Return true if the peer appears to getting close to encrypting too many messages with this key.
Perhaps if we send an alert well before their counter wraps, a buggy peer won’t make a terrible mistake here?
Note that there’s no reason to refuse to decrypt: the security failure has already happened.
Sourcepub fn wants_close_before_encrypt(&self) -> bool
pub fn wants_close_before_encrypt(&self) -> bool
Return true if we are getting close to encrypting too many messages with our encryption key.
Sourcepub fn encrypt_exhausted(&self) -> bool
pub fn encrypt_exhausted(&self) -> bool
Return true if we outright refuse to do anything with the encryption key.
Sourcepub fn decrypt_incoming(
&mut self,
encr: OpaqueMessage,
) -> Result<PlainMessage, Error>
pub fn decrypt_incoming( &mut self, encr: OpaqueMessage, ) -> Result<PlainMessage, Error>
Decrypt a TLS message.
encr is a decoded message allegedly received from the peer.
If it can be decrypted, its decryption is returned. Otherwise,
an error is returned.
Sourcepub fn encrypt_outgoing(
&mut self,
plain: BorrowedPlainMessage<'_>,
) -> OpaqueMessage
pub fn encrypt_outgoing( &mut self, plain: BorrowedPlainMessage<'_>, ) -> OpaqueMessage
Encrypt a TLS message.
plain is a TLS message we’d like to send. This function
panics if the requisite keying material hasn’t been established yet.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RecordLayer
impl !RefUnwindSafe for RecordLayer
impl Send for RecordLayer
impl Sync for RecordLayer
impl Unpin for RecordLayer
impl !UnwindSafe for RecordLayer
Blanket Implementations§
§impl<Head, T> Append<T> for Head
impl<Head, T> Append<T> for Head
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);