Skip to main content

Credentials

Struct Credentials 

Source
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

Source

pub fn new(user: impl Into<String>, password: impl Into<String>) -> Self

A user name and password pair.

Source

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.

Source

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.

Source

pub fn user(&self) -> Option<&str>

The configured user name, if any.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for Credentials

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Reports which halves are set and neither of their values.

Written by hand rather than derived so that no {:?} anywhere — this crate’s, the caller’s, or a panic message’s — can print a credential.

Source§

impl Default for Credentials

Source§

fn default() -> Credentials

Returns the “default value” for a type. Read more
Source§

impl Eq for Credentials

Source§

impl PartialEq for Credentials

Source§

fn eq(&self, other: &Credentials) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Credentials

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more