pub struct AnnotationDef {
pub name: String,
pub name_span: Span,
pub doc_comment: Option<DocComment>,
pub params: Vec<FunctionParameter>,
pub allowed_targets: Option<Vec<AnnotationTargetKind>>,
pub handlers: Vec<AnnotationHandler>,
pub span: Span,
}Expand description
Annotation definition with lifecycle hooks
Annotations are Shape’s aspect-oriented programming mechanism. They can define handlers for different lifecycle events:
annotation pattern() {
on_define(fn, ctx) { ctx.registry("patterns").set(fn.name, fn); }
metadata() { return { is_pattern: true }; }
}Fields§
§name: String§name_span: Span§doc_comment: Option<DocComment>§params: Vec<FunctionParameter>Annotation parameters (e.g., period in @warmup(period))
allowed_targets: Option<Vec<AnnotationTargetKind>>Optional explicit target restrictions from targets: [...].
If None, target applicability is inferred from handler kinds.
handlers: Vec<AnnotationHandler>Lifecycle handlers (on_define, before, after, metadata)
span: SpanFull span of the annotation definition
Trait Implementations§
Source§impl Clone for AnnotationDef
impl Clone for AnnotationDef
Source§fn clone(&self) -> AnnotationDef
fn clone(&self) -> AnnotationDef
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AnnotationDef
impl Debug for AnnotationDef
Source§impl<'de> Deserialize<'de> for AnnotationDef
impl<'de> Deserialize<'de> for AnnotationDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AnnotationDef
impl PartialEq for AnnotationDef
Source§impl Serialize for AnnotationDef
impl Serialize for AnnotationDef
impl StructuralPartialEq for AnnotationDef
Auto Trait Implementations§
impl Freeze for AnnotationDef
impl RefUnwindSafe for AnnotationDef
impl Send for AnnotationDef
impl Sync for AnnotationDef
impl Unpin for AnnotationDef
impl UnsafeUnpin for AnnotationDef
impl UnwindSafe for AnnotationDef
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
Mutably borrows from an owned value. Read more