pub enum Expr {
Show 32 variants
Divine {
template: StringTemplate,
result_ty: Option<TypeExpr>,
span: Span,
},
Summon {
agent: Ident,
fields: Vec<FieldInit>,
span: Span,
},
Await {
handle: Box<Expr>,
timeout: Option<Box<Expr>>,
span: Span,
},
Send {
handle: Box<Expr>,
message: Box<Expr>,
span: Span,
},
Yield {
value: Box<Expr>,
span: Span,
},
Call {
name: Ident,
type_args: Vec<TypeExpr>,
args: Vec<Expr>,
span: Span,
},
Apply {
callee: Box<Expr>,
args: Vec<Expr>,
span: Span,
},
SelfMethodCall {
method: Ident,
args: Vec<Expr>,
span: Span,
},
SelfField {
field: Ident,
span: Span,
},
Binary {
op: BinOp,
left: Box<Expr>,
right: Box<Expr>,
span: Span,
},
Unary {
op: UnaryOp,
operand: Box<Expr>,
span: Span,
},
List {
elements: Vec<Expr>,
span: Span,
},
Literal {
value: Literal,
span: Span,
},
Var {
name: Ident,
span: Span,
},
Paren {
inner: Box<Expr>,
span: Span,
},
StringInterp {
template: StringTemplate,
span: Span,
},
Match {
scrutinee: Box<Expr>,
arms: Vec<MatchArm>,
span: Span,
},
RecordConstruct {
name: Ident,
type_args: Vec<TypeExpr>,
fields: Vec<FieldInit>,
span: Span,
},
FieldAccess {
object: Box<Expr>,
field: Ident,
span: Span,
},
Receive {
span: Span,
},
Try {
expr: Box<Expr>,
span: Span,
},
Catch {
expr: Box<Expr>,
error_bind: Option<Ident>,
recovery: Box<Expr>,
span: Span,
},
Fail {
error: Box<Expr>,
span: Span,
},
Retry {
count: Box<Expr>,
delay: Option<Box<Expr>>,
on_errors: Option<Vec<Expr>>,
body: Box<Expr>,
span: Span,
},
Trace {
message: Box<Expr>,
span: Span,
},
Closure {
params: Vec<ClosureParam>,
body: Box<Expr>,
span: Span,
},
Tuple {
elements: Vec<Expr>,
span: Span,
},
TupleIndex {
tuple: Box<Expr>,
index: usize,
span: Span,
},
Map {
entries: Vec<MapEntry>,
span: Span,
},
VariantConstruct {
enum_name: Ident,
type_args: Vec<TypeExpr>,
variant: Ident,
payload: Option<Box<Expr>>,
span: Span,
},
ToolCall {
tool: Ident,
function: Ident,
args: Vec<Expr>,
span: Span,
},
Reply {
message: Box<Expr>,
span: Span,
},
}Expand description
An expression.
Variants§
Divine
LLM divination: divine("template") or divine("template" -> Type)
Fields
template: StringTemplateThe prompt template (may contain {ident} interpolations).
Summon
Agent summoning: summon AgentName { field: value, ... }
Fields
Await
Await: await expr or await expr timeout(ms)
Fields
Send
Send message: send(handle, message)
Fields
Yield
Yield value: yield(value)
Call
Function call: name(args) or name::<T, U>(args) (turbofish)
Fields
Apply
Apply expression: call an arbitrary expression as a function.
Used for method calls on values: expr.method(args) becomes
Apply { callee: FieldAccess { object: expr, field: method }, args }
Fields
SelfMethodCall
Method call on self: self.method(args)
Fields
SelfField
Self field access: self.field
Binary
Binary operation: left op right
Fields
Unary
Unary operation: op operand
Fields
List
List literal: [a, b, c]
Literal
Literal value.
Var
Variable reference.
Paren
Parenthesized expression: (expr)
Fields
StringInterp
Interpolated string: "Hello, {name}!"
Fields
template: StringTemplateThe string template with interpolations.
Match
Match expression: match expr { Pattern => expr, ... }
Fields
RecordConstruct
Record construction: Point { x: 1, y: 2 } or Pair::<Int, String> { first: 1, second: "hi" }
Fields
FieldAccess
Field access: record.field
Fields
Receive
Receive message from mailbox: receive()
Try
Try expression: try expr — propagates failure upward.
Catch
Catch expression: expr catch { recovery } or expr catch(e) { recovery }.
Fields
Fail
Fail expression: fail "message" or fail Error { ... }.
Type is Never - this expression never returns.
Fields
Retry
Retry expression: retry(3) { ... } or retry(3, delay: 1000) { ... }
Fields
Trace
Trace expression: trace("message") for emitting trace events.
Fields
Closure
Closure expression: |params| body
Fields
params: Vec<ClosureParam>The closure parameters.
Tuple
Tuple literal: (a, b, c)
TupleIndex
Tuple index access: tuple.0
Fields
Map
Map literal: { key: value, ... } or {}
VariantConstruct
Enum variant construction: MyEnum.Variant or Either::<L, R>.Left(payload)
Fields
ToolCall
Tool function call (RFC-0011): Http.get(url)
Fields
Reply
Reply to current message (Phase 3 session types): reply(message)
Only valid inside on message handlers when the agent follows a protocol.
Implementations§
Trait Implementations§
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
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,
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more