pub struct TlsConfig { /* private fields */ }Expand description
What a store needs to speak TLS to somewhere this machine does not already trust.
Data only — no client type appears anywhere in it, which is what makes
it the same three settings in all seven crates and what makes it
expressible from a language that has never heard of tonic.
Empty by default, and an empty one is not “no TLS”: it is the platform’s own trust store, which is what a public certificate authority needs and what every store already did.
See the module documentation for what each store can express and for why there is no way to turn verification off.
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn new() -> TlsConfig
pub fn new() -> TlsConfig
An empty configuration: the platform’s trust store, no client certificate.
Sourcepub fn with_ca_certificate_file(self, path: impl Into<PathBuf>) -> TlsConfig
pub fn with_ca_certificate_file(self, path: impl Into<PathBuf>) -> TlsConfig
Trust the certificate authority in this PEM file.
The file may hold several certificates; all of them are trusted, which is what a private CA with an intermediate needs.
The file is read when the store builds its client, not here — so a rotated CA is picked up by rebuilding the source, and a missing file is an error naming it rather than a panic in a builder chain.
Sourcepub fn with_ca_certificate_pem(self, pem: impl Into<Vec<u8>>) -> TlsConfig
pub fn with_ca_certificate_pem(self, pem: impl Into<Vec<u8>>) -> TlsConfig
Trust the certificate authority in these PEM bytes.
For a program that already has the material — from a secrets manager, from its own configuration — and should not have to put it on a disk for a client to read back.
Sourcepub fn with_client_certificate_files(
self,
certificate: impl Into<PathBuf>,
key: impl Into<PathBuf>,
) -> TlsConfig
pub fn with_client_certificate_files( self, certificate: impl Into<PathBuf>, key: impl Into<PathBuf>, ) -> TlsConfig
Present this client certificate and private key (mTLS).
Both are PEM files. certificate may be a chain; the leaf comes
first, as every TLS stack here expects.
Sourcepub fn with_client_certificate_pem(
self,
certificate: impl Into<Vec<u8>>,
key: impl Into<Vec<u8>>,
) -> TlsConfig
pub fn with_client_certificate_pem( self, certificate: impl Into<Vec<u8>>, key: impl Into<Vec<u8>>, ) -> TlsConfig
Present this client certificate and private key (mTLS), from bytes.
The private key is the sharpest secret this crate handles. It is
never rendered by Debug, never quoted into an
error, and never written anywhere: it goes from here into the
client’s own key type and stops.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this asks for nothing at all.
A store uses it to tell “the caller wants the platform defaults” from “the caller wants something”, which is the difference between leaving its client alone and building one.
Sourcepub fn ca_certificate(&self) -> Option<&Pem>
pub fn ca_certificate(&self) -> Option<&Pem>
The certificate authority to trust, if one was named.
Sourcepub fn client_certificate(&self) -> Option<&ClientCertificate>
pub fn client_certificate(&self) -> Option<&ClientCertificate>
The client certificate to present, if one was named.
Trait Implementations§
impl Eq for TlsConfig
impl StructuralPartialEq for TlsConfig
Auto Trait Implementations§
impl Freeze for TlsConfig
impl RefUnwindSafe for TlsConfig
impl Send for TlsConfig
impl Sync for TlsConfig
impl Unpin for TlsConfig
impl UnsafeUnpin for TlsConfig
impl UnwindSafe for TlsConfig
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
impl<T> MaybeSendSync for T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§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();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§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();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§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();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§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();Source§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>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§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);