pub struct Server { /* private fields */ }Expand description
Everything the HTTP layer serves from.
Built by Server::start, shared behind an Arc by the router, and
immutable afterwards: sections are established at startup and the set
does not change while the process runs. Adding one is a restart, which is
the same answer the rest of this workspace gives to “where do the sources
live”.
Implementations§
Source§impl Server
impl Server
Sourcepub fn start(config: &ServerConfig) -> Result<Self, StartupError>
pub fn start(config: &ServerConfig) -> Result<Self, StartupError>
Loads every section and refuses to start if anything is wrong.
The order matters: ServerConfig::validate runs first and nothing
is opened if it refuses, so a server that would have been
world-readable never gets as far as reading a secret off disk.
A section that will not load at startup is fatal. A config server that comes up serving nothing for one application is a silent outage for whoever needed it — better to fail the deployment.
§Errors
A Refusal, a section that will not load, or a watch that will not
start.
Sourcepub fn start_with(
config: &ServerConfig,
audit: impl AuditSink,
) -> Result<Self, StartupError>
pub fn start_with( config: &ServerConfig, audit: impl AuditSink, ) -> Result<Self, StartupError>
Sourcepub fn address(&self) -> SocketAddr
pub fn address(&self) -> SocketAddr
The address the binary listens on.
Sourcepub fn tls(&self) -> Option<&Tls>
Available on crate feature tls only.
pub fn tls(&self) -> Option<&Tls>
tls only.The loaded TLS configuration, or None for a server that expects a
terminator in front of it.
What serve_tls needs, and what tells an
embedder which of the two serving paths to take.
Sourcepub fn authenticate(&self, authorization: Option<&str>) -> Option<Principal>
pub fn authenticate(&self, authorization: Option<&str>) -> Option<Principal>
Who is calling, given the raw Authorization header.
Sourcepub fn section(&self, application: &str, profile: &str) -> Option<&Arc<Section>>
pub fn section(&self, application: &str, profile: &str) -> Option<&Arc<Section>>
The section serving application at profile, if one does.
Call this only after authorising. It is the lookup that would otherwise tell a caller whether a section exists, and the whole not-an-oracle property rests on nothing reaching it that has not already been granted the application.
Sourcepub fn record(&self, entry: &AuditEntry)
pub fn record(&self, entry: &AuditEntry)
Records one request.
Sourcepub fn streams_enabled(&self) -> bool
pub fn streams_enabled(&self) -> bool
Whether this server serves change streams at all.
Sourcepub fn open_stream(&self) -> Option<StreamPermit>
pub fn open_stream(&self) -> Option<StreamPermit>
A place in the change-stream ceiling, if there is one free.
A compare-and-swap loop rather than a fetch-add and a refund: an increment that overshoots is briefly visible to another request, which would let two callers each see the ceiling exceeded and both back off.
Sourcepub fn open_streams(&self) -> usize
pub fn open_streams(&self) -> usize
How many change streams are open. For the tests and for a deployment that wants the number in its own metrics.
Source§impl Server
impl Server
Sourcepub fn posture(&self) -> &'static str
Available on crate feature tls only.
pub fn posture(&self) -> &'static str
tls only.How this server’s own socket is protected, in a few words — for a
startup line, a Debug and an operator’s first question.
One of none, tls or tls, client certificate required. Never a
path, never a subject, never a key: it says which of the three shapes
this process is in and nothing about the material it is in it with.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Server
impl !UnwindSafe for Server
impl Freeze for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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);