Expand description
The hidden __handler protocol between #[handlers] and a transport’s handler attribute
(transports DESIGN §2.1, §2.5, X1, X2).
#[handlers] expands first. For each handler it removes the method’s enhancer and #[meta]
attributes and appends, after the transport attribute,
#[::ulo::__private::__handler(<name>,
controller(<impl-level enhancer attrs>),
method(<method-level enhancer attrs>),
meta(controller(<impl-level meta exprs>), method(<method-level meta exprs>)))]A method-level enhancer attribute or meta expression written inside cfg_attr carries one
#[cfg(<predicate>)] per enclosing predicate in front of it, method(#[cfg(feature = "x")] guards(AuthGuard)), and whatever a transport generates from it is compiled under those gates
(EnhancerAttr::gates, MetaExpr::gates). A handler whose transport attribute sits inside
cfg_attr receives the attribute inside a cfg_attr with the same predicates, so it is
present exactly where the transport attribute is.
The transport attribute removes it with take_handler_attr and owes three items inside the
impl, every <name> the method’s identifier without r#:
const __ULO_KEY_<name>: &'static str = <Tr as ::ulo::Transport>::KEY;(X1).const __ULO_CHECKS_<name>: () = { .. };, the pairwise body-consumer assertions,()when the handler has fewer than two parameters.#[handlers]reads it from a freeconst _: () = <Ctrl>::__ULO_CHECKS_<name>;, which evaluates it unconditionally, or on a generic controller fromHandlers::mount, which evaluates it whenmountis instantiated.fn __ulo_mount_<name><__UloV0, ..>(m: &mut ::ulo::Mount<'_>, shared: &::ulo::__private::Shared<(Arc<__UloV0>, ..)>), one type parameter per impl-levelvalueentry in the order written across the impl’s enhancer attributes, each bounded by its role for this transport when the entry applies to it and unbounded otherwise (X2).#[handlers]’sHandlers::mountbuilds theSharedonce and calls every mount function with it.
crate::emit::MountFn writes all three.
Re-exports§
pub use enhancers::EnhancerAttr;pub use enhancers::Entry;pub use enhancers::Form;pub use enhancers::Role;pub use scope::SCOPE_WORDS;pub use scope::ScopeArg;
Modules§
- enhancers
- The enhancer attributes’ grammar, shared by
#[handlers], which parses them off the impl and its methods, and by every transport attribute, which reads them back out of__handler. - scope
- The scope word, written the same way wherever a scope is declared:
#[injectable(execution)]on a type,with(execution) = ..on a closure.
Structs§
- Handler
Tokens - The tokens
__handler(..)carries for one handler. - Meta
Expr - One
#[meta(..)]expression. - Meta
Tokens - The
#[meta(..)]expressions of one handler, at both tiers, in the order written.
Functions§
- is_meta
- Whether
attris#[meta(..)], by its path’s last segment. - meta_
exprs - The expressions of one
#[meta(..)], each compiled undergates. - outside_
handlers - The error a transport attribute named
attr_namereports whentake_handler_attrfinds no__handler: it sits outside a#[handlers]impl, or inside one on a method where#[handlers]took another attribute for the transport attribute and gated the hand-off on that one’scfg_attr. - take_
handler_ attr - Removes the
__handlerattribute#[handlers]appended to a handler and parses it.Nonewhen the method carries none, which the transport attribute reports withoutside_handlers. - take_
meta - The
#[meta(..)]attributes inattrs, removed and parsed, their expressions in order and ungated.