pub struct Credentials { /* private fields */ }Expand description
The user name and password a session is created with.
Both are free strings, interpreted and verified by the server’s Metadata
Adapter — this crate never inspects them and imposes no format
[docs/spec/03-requests.md §2.1]. Many Adapter Sets, including the public
demo one, authenticate nobody and accept Credentials::anonymous.
§Secrecy
This crate never reads credentials from the environment, from a file, or
from anywhere else: you supply them. Neither half is ever logged, neither
appears in any Error this crate produces, and the
hand-written Debug implementation redacts both, so a {:?} of a
config struct that happens to contain one is safe.
The user name is redacted as well as the password because it is not always
the innocuous half: adapters routinely authenticate with an account
identifier or an API key as the user name, and a Debug that printed it
would put that in a log by accident. When you want it, ask for it —
Credentials::user returns it and says so at the call site.
use lightstreamer_rs::Credentials;
let credentials = Credentials::new("alice", "hunter2");
let rendered = format!("{credentials:?}");
assert!(!rendered.contains("hunter2"));
assert!(!rendered.contains("alice"));Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn new(user: impl Into<String>, password: impl Into<String>) -> Self
pub fn new(user: impl Into<String>, password: impl Into<String>) -> Self
A user name and password pair.
Sourcepub const fn anonymous() -> Self
pub const fn anonymous() -> Self
No user name and no password.
The Metadata Adapter is still asked to authenticate the session — it
simply receives a null user name, and may well accept it
[docs/spec/03-requests.md §2.1]. This is what the public demo server
expects.
Sourcepub fn user_only(user: impl Into<String>) -> Self
pub fn user_only(user: impl Into<String>) -> Self
A user name with no password, for Adapter Sets that identify a user without authenticating one.
Sourcepub const fn has_password(&self) -> bool
pub const fn has_password(&self) -> bool
Whether a password was supplied.
There is deliberately no accessor that returns the password itself: it goes to the server and nowhere else.
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more