pub struct Keyring { /* private fields */ }encryption only.Expand description
A lock-free and thread-safe container for a set of encryption keys. The keyring contains all key data used internally by memberlist.
If creating a keyring with multiple keys, one key must be designated primary by passing it as the primaryKey. If the primaryKey does not exist in the list of secondary keys, it will be automatically added at position 0.
Implementations§
Source§impl Keyring
impl Keyring
Sourcepub fn new(primary_key: SecretKey) -> Self
pub fn new(primary_key: SecretKey) -> Self
Constructs a new container for a primary key. The keyring contains all key data used internally by memberlist.
If only a primary key is passed, then it will be automatically added to the keyring.
A key should be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
Sourcepub fn with_keys(
primary_key: SecretKey,
keys: impl Iterator<Item = impl Into<SecretKey>>,
) -> Self
pub fn with_keys( primary_key: SecretKey, keys: impl Iterator<Item = impl Into<SecretKey>>, ) -> Self
Constructs a new container for a set of encryption keys. The keyring contains all key data used internally by memberlist.
If only a primary key is passed, then it will be automatically added to the keyring. If creating a keyring with multiple keys, one key must be designated primary by passing it as the primaryKey. If the primaryKey does not exist in the list of secondary keys, it will be automatically added.
A key should be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
Sourcepub fn primary_key(&self) -> SecretKey
pub fn primary_key(&self) -> SecretKey
Returns the key on the ring at position 0. This is the key used for encrypting messages, and is the first key tried for decrypting messages.
Sourcepub fn remove(&self, key: &[u8]) -> Result<(), KeyringError>
pub fn remove(&self, key: &[u8]) -> Result<(), KeyringError>
Drops a key from the keyring. This will return an error if the key requested for removal is currently at position 0 (primary key).
Sourcepub fn insert(&self, key: SecretKey)
pub fn insert(&self, key: SecretKey)
Install a new key on the ring. Adding a key to the ring will make it available for use in decryption. If the key already exists on the ring, this function will just return noop.
key should be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Keyring
impl<'de> Deserialize<'de> for Keyring
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Auto Trait Implementations§
impl !RefUnwindSafe for Keyring
impl !UnwindSafe for Keyring
impl Freeze for Keyring
impl Send for Keyring
impl Sync for Keyring
impl Unpin for Keyring
impl UnsafeUnpin for Keyring
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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