pub struct Credentials { /* private fields */ }Expand description
A username and password that may be replaced while the process runs.
Cheap to clone — every clone shares one set of credentials, which is the point: the task that fetches a new one and the pool that opens connections with it are looking at the same value.
Implementations§
Source§impl Credentials
impl Credentials
pub fn new(user: impl Into<String>, password: impl Into<String>) -> Credentials
pub fn user(&self) -> String
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Which generation the current credentials belong to.
Sourcepub fn rotate(
&self,
user: impl Into<String>,
password: impl Into<String>,
) -> u64
pub fn rotate( &self, user: impl Into<String>, password: impl Into<String>, ) -> u64
Replace them, and retire every connection opened with the old ones.
Returns the new generation. Rotating to the same values still counts as a rotation: a caller doing that is saying the old connections are no longer wanted, and second-guessing it here would silently keep them.
Sourcepub fn is_current(&self, generation: u64) -> bool
pub fn is_current(&self, generation: u64) -> bool
Whether a connection opened under generation is still current.
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnsafeUnpin for Credentials
impl UnwindSafe for Credentials
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
Mutably borrows from an owned value. Read more