Skip to main content

Services

Struct Services 

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

The service slots of a registry and the values contributed to them, fixed once the registry is built.

assemble produces it during the registry build, and FlmRegistry::services returns it. Every run shares it, and nothing changes it. Read a service by its type (Services::service, Services::services) or, where two slots have one type, by slot name (Services::service_named, Services::services_named). A stage normally reads a service through its context (StageCx::service) rather than here.

Implementations§

Source§

impl Services

Source

pub fn new() -> Services

Returns services with no slot and no value: what a registry holds when no feature declares a service slot.

Source

pub fn slot(&self, name: &str) -> Option<&SlotDecl>

Returns the declaration of the service slot named name, or None when no slot has that name.

Source

pub fn slots(&self) -> impl Iterator<Item = &SlotDecl> + '_

Returns every declared service slot, in name order.

The order does not depend on the order in which the features registered, so a listing built from it is the same in every build.

Source

pub fn slots_of<S: ?Sized + Any>(&self) -> &[Name]

Returns the names of the service slots whose values have the type S, in name order.

When it returns more than one name, a contribution by type alone is refused as ambiguous, and a read by type alone takes the slots in this order; the operations that take a slot name select one slot.

Source

pub fn service<S: ?Sized + Any + Send + Sync>(&self) -> Option<&S>

Returns one service of type S: of the service slots whose values have that type, taken in name order, the first that holds a value gives the value that takes precedence in it (the first in the order of Services::services_by_precedence_named).

Write S as the type the slot declares: services.service::<dyn Fetcher>(). Returns None when no slot has the type, or when every such slot is empty; an absent service is a normal result, and the caller decides what to do about it.

See also Services::service_named, for a slot named directly.

Source

pub fn services<S: ?Sized + Any + Send + Sync>( &self, ) -> impl Iterator<Item = &S> + '_

Returns every service of type S: the values of every service slot whose values have that type, the slots taken in name order and the values of each slot in their assembled order (see Arity::OrderedMany).

Source

pub fn service_named<S: ?Sized + Any + Send + Sync>( &self, name: &str, ) -> Option<&S>

Returns the value of the service slot named name that takes precedence, read as an S: the first in the order of Services::services_by_precedence_named, so that between features, the value of the feature placed last in the feature order.

Returns None when the slot does not exist, holds no value, or holds values of another type.

Source

pub fn shared_service_named<S: ?Sized + Any + Send + Sync>( &self, name: &str, ) -> Option<&Arc<S>>

Returns the value of the service slot named name that takes precedence, as Services::service_named does, as the shared pointer it was contributed as.

Use it to keep that value beyond the borrow of the services, as Services::shared_named does for every value of a slot.

Source

pub fn services_named<S: ?Sized + Any + Send + Sync>( &self, name: &str, ) -> impl Iterator<Item = &S> + '_

Returns every value of the service slot named name, read as S, in their assembled order: the values contributed with contribute_first or contribute_first_to come first, then the others, each group in the order the values were contributed. Returns nothing when the slot does not exist or holds values of another type.

Source

pub fn services_by_precedence_named<S: ?Sized + Any + Send + Sync>( &self, name: &str, ) -> impl Iterator<Item = &S> + '_

Returns every value of the service slot named name, read as S, in the order of precedence: the values contributed with contribute_first or contribute_first_to first, then the others; within each of these two groups, the values of the feature placed last in the feature order first, each feature’s values in the order the feature contributed them, and the embedding program’s values last. Returns nothing when the slot does not exist or holds values of another type.

Read a slot in this order where its values are asked in turn until one answers, so that between features, the feature placed last wins (see the order of a slot’s values).

Source

pub fn shared_named<S: ?Sized + Any + Send + Sync>( &self, name: &str, ) -> impl Iterator<Item = &Arc<S>> + '_

Returns every value of the service slot named name, read as S, in the order of Services::services_named, each as the shared pointer it was contributed as.

Use it to keep a service beyond the registry build. A lowering rule, for example, has no access to the registry’s services while it runs, so a finalizer (Finalizer) hands it the values of a slot: the pointer is cloned, and the value itself is shared, not copied.

Source

pub fn count(&self, name: &str) -> usize

Returns how many values the service slot named name holds: zero for a slot that is empty or does not exist.

Source

pub fn peer_contributions(&self) -> &[PeerContribution]

Returns the record of every peer contribution the features made, in the order they made them, each stating whether its service slot is declared.

A peer contribution whose slot no feature declares has resolved set to false, and its value was dropped when the slots were assembled. Every peer contribution has its own record, while the registry build reports one Note per feature and slot.

Trait Implementations§

Source§

impl Debug for Services

Source§

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

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

impl Default for Services

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Services

§

impl !UnwindSafe for Services

§

impl Forget for Services

§

impl Freeze for Services
where *const LeafNode<Name, SlotDecl> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(Name, SlotDecl)>>: Freeze, *const LeafNode<Name, Vec<Arc<dyn Any + Send + Sync>>> is !null: Freeze, PhantomData<Box<(Name, Vec<Arc<dyn Any + Send + Sync>>)>>: Freeze, *const LeafNode<TypeKey, Vec<Name>> is !null: Freeze, PhantomData<Box<(TypeKey, Vec<Name>)>>: Freeze, *const u8 is !null: Freeze, PhantomData<PeerContribution>: Freeze,

§

impl Move for Services

§

impl Send for Services
where NodeRef<Owned, Name, SlotDecl, LeafOrInternal>: Send, BoxRaw<(Name, SlotDecl)>: Send, NodeRef<Owned, Name, Vec<Arc<dyn Any + Send + Sync>>, LeafOrInternal>: Send, BoxRaw<(Name, Vec<Arc<dyn Any + Send + Sync>>)>: Send, NodeRef<Owned, TypeKey, Vec<Name>, LeafOrInternal>: Send, BoxRaw<(TypeKey, Vec<Name>)>: Send, RawVecInner: Send, Arc<str>: Send, &'static str: Send, TypeId: Send,

§

impl Sync for Services
where NodeRef<Owned, Name, SlotDecl, LeafOrInternal>: Sync, BoxRaw<(Name, SlotDecl)>: Sync, NodeRef<Owned, Name, Vec<Arc<dyn Any + Send + Sync>>, LeafOrInternal>: Sync, BoxRaw<(Name, Vec<Arc<dyn Any + Send + Sync>>)>: Sync, NodeRef<Owned, TypeKey, Vec<Name>, LeafOrInternal>: Sync, BoxRaw<(TypeKey, Vec<Name>)>: Sync, RawVecInner: Sync, Arc<str>: Sync, TypeId: Sync,

§

impl Unpin for Services
where *const LeafNode<Name, SlotDecl> is !null: Unpin, Box<(Name, SlotDecl)>: Unpin, *const LeafNode<Name, Vec<Arc<dyn Any + Send + Sync>>> is !null: Unpin, Box<(Name, Vec<Arc<dyn Any + Send + Sync>>)>: Unpin, *const LeafNode<TypeKey, Vec<Name>> is !null: Unpin, Box<(TypeKey, Vec<Name>)>: Unpin, *const u8 is !null: Unpin, Arc<str>: Unpin, &'static str: Unpin, *const (): Unpin,

§

impl UnsafeUnpin for Services

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.