Skip to main content

ConfigSections

Struct ConfigSections 

Source
pub struct ConfigSections { /* private fields */ }
Expand description

The sections a request reads, and how to read each one.

Built once, at startup, and handed to the framework adapter. Each entry is a closure the adapter calls when a request begins — never during it, which is what makes the reads agree.

Implementations§

Source§

impl Sections

Source

pub fn new() -> Sections

An empty list.

Source

pub fn section<T, F>(self, read: F) -> Sections
where T: Any + Send + Sync, F: Fn() -> Option<Arc<T>> + Send + Sync + 'static,

Adds one section, read by read.

let sections = Sections::new().section(try_current);

In a service read is || Database::try_current(), or move || handle.current() for a Dynamic<T>.

Registering the same type twice keeps the last reader, so a composed list can override one entry without rebuilding it.

Source

pub fn section_with_generation<T, F, G>( self, read: F, generation: G, ) -> Sections
where T: Any + Send + Sync, F: Fn() -> Option<Arc<T>> + Send + Sync + 'static, G: Fn() -> u64 + Send + Sync + 'static,

Adds one section, with the install counter that says when it moved.

What sections! uses. The counter lets take tell a snapshot that straddled a reload from one that did not; a section registered through section has none, and a list containing one cannot make that check.

Source

pub fn is_consistent(&self) -> bool

Whether every section can say when it last moved.

false when any was registered through section, which takes a reader and nothing else — take then reads once without checking.

Source

pub fn take(&self) -> Snapshot

Reads every section once.

Called by the adapter when a request begins. A section that has not loaded is left out rather than failing the request: the handler that asks for it gets NotInScope::NotLoaded, and a handler that does not ask is unaffected.

Source

pub fn len(&self) -> usize

How many sections are registered.

Source

pub fn is_empty(&self) -> bool

Whether nothing is registered.

Source

pub fn names(&self) -> Vec<&'static str>

The registered type names, in order.

Trait Implementations§

Source§

impl Debug for Sections

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Sections

Source§

fn default() -> Sections

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

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> 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, 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