pub struct EventDecl {
pub name: Ident,
pub annotations: Vec<Annotation>,
pub body: RecordBody,
pub documentation: Option<String>,
pub span: Span,
pub trivia: Trivia,
}Expand description
event Name = { fields } — a typed fact a context may emit and other
contexts’ subscriber services may receive (Events track, slice 0, spine
#936). Record body only in slice 0 — pattern refinement (subscription
side, slice 1) and default-valued fields for additive versioning (slice
3a) both extend a record body, so nothing here forecloses them. An
optional @schema(N) annotation (slice 3b) asserts the event’s current
wire schema version, embedded into env.schemaVersion at emission — see
EventDecl::schema_version. Legal only inside a context —
checker-enforced (bynk.event.outside_context), not grammar, mirroring
how capability/provides are commons-rejected at the parser while
event instead follows messages’ precedent (ADR 0272) of parsing
uniformly and letting the checker place it, since unlike
capability/provides an event has no meaning to reject early inside
an adapter either.
Fields§
§name: Ident§annotations: Vec<Annotation>Every @-annotation attached to this declaration. The parser stays
permissive (zero or more, same as store field / messages
annotations); the closed registry (today: @schema alone) and its
argument shape are a checker concern (bynk.event.unknown_annotation
/ bynk.event.bad_schema_version), not a parse error.
body: RecordBody§documentation: Option<String>Documentation block attached to this declaration.
span: Span§trivia: TriviaImplementations§
Source§impl EventDecl
impl EventDecl
Sourcepub fn as_type_decl(&self) -> TypeDecl
pub fn as_type_decl(&self) -> TypeDecl
A synthetic TypeDecl with this event’s name and record body, so an
event registers into the ordinary types symbol table and reuses
every existing type-reference/exports/consumes/construction check —
no non-generic type parameters, no separate resolution path. Callers
that need to know a name is specifically an event (owner-only
emission, from Events(E)/Events.emit[E]’s “must be an event, not
just any type” gate) track that separately, alongside this.
Deliberately lossy: a TypeDecl has no annotations, so @schema(N)
does not survive this conversion. Nothing downstream of this
synthesis needs the event’s schema version — only the emitter’s own
Events.emit lowering does, and it reads EventDecl::schema_version
directly off the real declaration instead.
Sourcepub fn schema_version(&self) -> i64
pub fn schema_version(&self) -> i64
This event’s declared wire schema version (Events slice 3b, #978):
the positive Int literal argument of its sole @schema(N)
annotation, or 1 if the annotation is absent — identical to every
event’s behaviour before this annotation existed. A malformed
@schema (non-positive, non-literal, wrong arity, labelled, or
duplicated) has already been reported by the checker
(bynk.event.bad_schema_version); this falls back to 1 rather than
re-deriving that diagnostic.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventDecl
impl RefUnwindSafe for EventDecl
impl Send for EventDecl
impl Sync for EventDecl
impl Unpin for EventDecl
impl UnsafeUnpin for EventDecl
impl UnwindSafe for EventDecl
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§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();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§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();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§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();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§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();§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>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§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);