1use crate::span::{Span, Spanned};
6
7#[derive(Debug, Clone, PartialEq)]
15pub struct Attribute {
16 pub name: Ident,
17 pub args: Option<AttrArgs>,
18 pub is_inner: bool, }
20
21#[derive(Debug, Clone, PartialEq)]
23pub enum AttrArgs {
24 Paren(Vec<AttrArg>),
26 Eq(Box<Expr>),
28}
29
30#[derive(Debug, Clone, PartialEq)]
32pub enum AttrArg {
33 Ident(Ident),
35 Literal(Literal),
37 Nested(Attribute),
39 KeyValue { key: Ident, value: Box<Expr> },
41}
42
43#[derive(Debug, Clone, PartialEq, Default)]
45pub struct CrateConfig {
46 pub no_std: bool,
48 pub no_main: bool,
50 pub features: Vec<String>,
52 pub target: Option<TargetConfig>,
54 pub linker: Option<LinkerConfig>,
56}
57
58#[derive(Debug, Clone, PartialEq, Default)]
60pub struct TargetConfig {
61 pub arch: Option<String>, pub os: Option<String>, pub abi: Option<String>, pub features: Vec<String>, }
66
67#[derive(Debug, Clone, PartialEq, Default)]
69pub struct LinkerConfig {
70 pub script: Option<String>,
72 pub entry_point: Option<String>,
74 pub base_address: Option<u64>,
76 pub stack_size: Option<u64>,
78 pub flags: Vec<String>,
80 pub memory_regions: Vec<MemoryRegion>,
82 pub sections: Vec<SectionConfig>,
84}
85
86#[derive(Debug, Clone, PartialEq)]
88pub struct MemoryRegion {
89 pub name: String,
90 pub origin: u64,
91 pub length: u64,
92 pub attributes: MemoryAttributes,
93}
94
95#[derive(Debug, Clone, PartialEq, Default)]
97pub struct MemoryAttributes {
98 pub readable: bool,
99 pub writable: bool,
100 pub executable: bool,
101}
102
103#[derive(Debug, Clone, PartialEq)]
105pub struct SectionConfig {
106 pub name: String,
107 pub address: Option<u64>,
108 pub align: Option<u64>,
109 pub region: Option<String>,
110}
111
112#[derive(Debug, Clone, PartialEq)]
118pub struct SimdType {
119 pub element_type: Box<TypeExpr>,
121 pub lanes: u8,
123}
124
125#[derive(Debug, Clone, PartialEq, Copy)]
127pub enum SimdOp {
128 Add,
130 Sub,
131 Mul,
132 Div,
133 Neg,
134 Abs,
135 Min,
136 Max,
137
138 Eq,
140 Ne,
141 Lt,
142 Le,
143 Gt,
144 Ge,
145
146 HAdd, Dot, Shuffle,
152 Blend,
153
154 Load,
156 Store,
157 LoadAligned,
158 StoreAligned,
159
160 Cast,
162 Widen,
163 Narrow,
164
165 Sqrt,
167 Rsqrt, Rcp, Floor,
170 Ceil,
171 Round,
172
173 And,
175 Or,
176 Xor,
177 Not,
178 Shl,
179 Shr,
180}
181
182#[derive(Debug, Clone, PartialEq, Copy, Default)]
188pub enum MemoryOrdering {
189 Relaxed,
191 Acquire,
193 Release,
195 AcqRel,
197 #[default]
199 SeqCst,
200}
201
202#[derive(Debug, Clone, PartialEq, Copy)]
204pub enum AtomicOp {
205 Load,
206 Store,
207 Swap,
208 CompareExchange,
209 CompareExchangeWeak,
210 FetchAdd,
211 FetchSub,
212 FetchAnd,
213 FetchOr,
214 FetchXor,
215 FetchMin,
216 FetchMax,
217}
218
219#[derive(Debug, Clone, PartialEq)]
225pub enum DeriveTrait {
226 Debug,
228 Clone,
229 Copy,
230 Default,
231 PartialEq,
232 Eq,
233 PartialOrd,
234 Ord,
235 Hash,
236
237 Component, Resource, Bundle, Serialize,
244 Deserialize,
245
246 Custom(String),
248}
249
250#[derive(Debug, Clone, PartialEq, Default)]
252pub struct StructAttrs {
253 pub repr: Option<StructRepr>,
255 pub packed: bool,
257 pub align: Option<usize>,
259 pub simd: bool,
261 pub derives: Vec<DeriveTrait>,
263 pub outer_attrs: Vec<Attribute>,
265}
266
267#[derive(Debug, Clone, PartialEq)]
273pub enum BuiltinTrait {
274 Allocator,
276 Iterator,
278 IntoIterator,
280 Drop,
282 Default,
284 Deref,
286 DerefMut,
288 Index,
290 IndexMut,
292}
293
294#[derive(Debug, Clone, PartialEq)]
296pub struct SourceFile {
297 pub attrs: Vec<Attribute>,
299 pub config: CrateConfig,
301 pub items: Vec<Spanned<Item>>,
303}
304
305#[derive(Debug, Clone, PartialEq)]
307pub enum Item {
308 Function(Function),
309 Struct(StructDef),
310 Enum(EnumDef),
311 Trait(TraitDef),
312 Impl(ImplBlock),
313 TypeAlias(TypeAlias),
314 Module(Module),
315 Use(UseDecl),
316 Const(ConstDef),
317 Static(StaticDef),
318 Actor(ActorDef),
319 ExternBlock(ExternBlock),
320}
321
322#[derive(Debug, Clone, PartialEq)]
325pub struct ExternBlock {
326 pub abi: String, pub items: Vec<ExternItem>,
328}
329
330#[derive(Debug, Clone, PartialEq)]
332pub enum ExternItem {
333 Function(ExternFunction),
334 Static(ExternStatic),
335}
336
337#[derive(Debug, Clone, PartialEq)]
339pub struct ExternFunction {
340 pub visibility: Visibility,
341 pub name: Ident,
342 pub params: Vec<Param>,
343 pub return_type: Option<TypeExpr>,
344 pub variadic: bool, }
346
347#[derive(Debug, Clone, PartialEq)]
349pub struct ExternStatic {
350 pub visibility: Visibility,
351 pub mutable: bool,
352 pub name: Ident,
353 pub ty: TypeExpr,
354}
355
356#[derive(Debug, Clone, PartialEq, Default)]
358pub struct FunctionAttrs {
359 pub naked: bool,
361 pub inline: Option<InlineHint>,
363 pub calling_convention: Option<String>,
365 pub no_mangle: bool,
367 pub link_section: Option<String>,
369 pub export: bool,
371 pub panic_handler: bool,
373 pub entry: bool,
375 pub interrupt: Option<u32>,
377 pub align: Option<usize>,
379 pub cold: bool,
381 pub hot: bool,
383 pub test: bool,
385 pub outer_attrs: Vec<Attribute>,
387}
388
389#[derive(Debug, Clone, PartialEq)]
391pub enum InlineHint {
392 Hint,
394 Always,
396 Never,
398}
399
400#[derive(Debug, Clone, Copy, PartialEq, Eq)]
402pub enum Aspect {
403 Progressive,
405 Perfective,
407 Potential,
409 Resultative,
411}
412
413#[derive(Debug, Clone, PartialEq)]
415pub struct Function {
416 pub visibility: Visibility,
417 pub is_async: bool,
418 pub attrs: FunctionAttrs,
419 pub name: Ident,
420 pub aspect: Option<Aspect>, pub generics: Option<Generics>,
422 pub params: Vec<Param>,
423 pub return_type: Option<TypeExpr>,
424 pub where_clause: Option<WhereClause>,
425 pub body: Option<Block>,
426}
427
428#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
430pub enum Visibility {
431 #[default]
432 Private,
433 Public,
434 Crate,
435 Super,
436}
437
438#[derive(Debug, Clone, PartialEq)]
440pub struct Ident {
441 pub name: String,
442 pub evidentiality: Option<Evidentiality>,
443 pub affect: Option<Affect>,
444 pub span: Span,
445}
446
447#[derive(Debug, Clone, Copy, PartialEq, Eq)]
449pub enum Evidentiality {
450 Known, Uncertain, Reported, Paradox, }
455
456#[derive(Debug, Clone, PartialEq)]
458pub struct Affect {
459 pub sentiment: Option<Sentiment>,
460 pub sarcasm: bool, pub intensity: Option<Intensity>,
462 pub formality: Option<Formality>,
463 pub emotion: Option<Emotion>,
464 pub confidence: Option<Confidence>,
465}
466
467impl Default for Affect {
468 fn default() -> Self {
469 Affect {
470 sentiment: None,
471 sarcasm: false,
472 intensity: None,
473 formality: None,
474 emotion: None,
475 confidence: None,
476 }
477 }
478}
479
480impl Affect {
481 pub fn is_empty(&self) -> bool {
482 self.sentiment.is_none()
483 && !self.sarcasm
484 && self.intensity.is_none()
485 && self.formality.is_none()
486 && self.emotion.is_none()
487 && self.confidence.is_none()
488 }
489}
490
491#[derive(Debug, Clone, Copy, PartialEq, Eq)]
493pub enum Sentiment {
494 Positive, Negative, Neutral, }
498
499#[derive(Debug, Clone, Copy, PartialEq, Eq)]
501pub enum Intensity {
502 Up, Down, Max, }
506
507#[derive(Debug, Clone, Copy, PartialEq, Eq)]
509pub enum Formality {
510 Formal, Informal, }
513
514#[derive(Debug, Clone, Copy, PartialEq, Eq)]
516pub enum Emotion {
517 Joy, Sadness, Anger, Fear, Surprise, Love, }
524
525#[derive(Debug, Clone, Copy, PartialEq, Eq)]
527pub enum Confidence {
528 High, Medium, Low, }
532
533#[derive(Debug, Clone, PartialEq)]
535pub struct Param {
536 pub pattern: Pattern,
537 pub ty: TypeExpr,
538}
539
540#[derive(Debug, Clone, PartialEq)]
542pub struct Generics {
543 pub params: Vec<GenericParam>,
544}
545
546#[derive(Debug, Clone, PartialEq)]
547pub enum GenericParam {
548 Type {
549 name: Ident,
550 bounds: Vec<TypeExpr>,
551 evidentiality: Option<Evidentiality>,
552 },
553 Const {
554 name: Ident,
555 ty: TypeExpr,
556 },
557 Lifetime(String),
558}
559
560#[derive(Debug, Clone, PartialEq)]
562pub struct WhereClause {
563 pub predicates: Vec<WherePredicate>,
564}
565
566#[derive(Debug, Clone, PartialEq)]
567pub struct WherePredicate {
568 pub ty: TypeExpr,
569 pub bounds: Vec<TypeExpr>,
570}
571
572#[derive(Debug, Clone, PartialEq)]
574pub enum TypeExpr {
575 Path(TypePath),
577 Reference {
579 mutable: bool,
580 inner: Box<TypeExpr>,
581 },
582 Pointer {
584 mutable: bool,
585 inner: Box<TypeExpr>,
586 },
587 Array {
589 element: Box<TypeExpr>,
590 size: Box<Expr>,
591 },
592 Slice(Box<TypeExpr>),
594 Tuple(Vec<TypeExpr>),
596 Function {
598 params: Vec<TypeExpr>,
599 return_type: Option<Box<TypeExpr>>,
600 },
601 Evidential {
603 inner: Box<TypeExpr>,
604 evidentiality: Evidentiality,
605 },
606 Cycle {
608 modulus: Box<Expr>,
609 },
610 Simd {
612 element: Box<TypeExpr>,
613 lanes: u8,
614 },
615 Atomic(Box<TypeExpr>),
617 Never,
619 Infer,
621}
622
623#[derive(Debug, Clone, PartialEq)]
625pub struct TypePath {
626 pub segments: Vec<PathSegment>,
627}
628
629#[derive(Debug, Clone, PartialEq)]
630pub struct PathSegment {
631 pub ident: Ident,
632 pub generics: Option<Vec<TypeExpr>>,
633}
634
635#[derive(Debug, Clone, PartialEq)]
637pub enum StructRepr {
638 C,
640 Transparent,
642 Int(String),
644}
645
646#[derive(Debug, Clone, PartialEq)]
648pub struct StructDef {
649 pub visibility: Visibility,
650 pub attrs: StructAttrs,
651 pub name: Ident,
652 pub generics: Option<Generics>,
653 pub fields: StructFields,
654}
655
656#[derive(Debug, Clone, PartialEq)]
657pub enum StructFields {
658 Named(Vec<FieldDef>),
659 Tuple(Vec<TypeExpr>),
660 Unit,
661}
662
663#[derive(Debug, Clone, PartialEq)]
664pub struct FieldDef {
665 pub visibility: Visibility,
666 pub name: Ident,
667 pub ty: TypeExpr,
668}
669
670#[derive(Debug, Clone, PartialEq)]
672pub struct EnumDef {
673 pub visibility: Visibility,
674 pub name: Ident,
675 pub generics: Option<Generics>,
676 pub variants: Vec<EnumVariant>,
677}
678
679#[derive(Debug, Clone, PartialEq)]
680pub struct EnumVariant {
681 pub name: Ident,
682 pub fields: StructFields,
683 pub discriminant: Option<Expr>,
684}
685
686#[derive(Debug, Clone, PartialEq)]
688pub struct TraitDef {
689 pub visibility: Visibility,
690 pub name: Ident,
691 pub generics: Option<Generics>,
692 pub supertraits: Vec<TypeExpr>,
693 pub items: Vec<TraitItem>,
694}
695
696#[derive(Debug, Clone, PartialEq)]
697pub enum TraitItem {
698 Function(Function),
699 Type {
700 name: Ident,
701 bounds: Vec<TypeExpr>,
702 },
703 Const {
704 name: Ident,
705 ty: TypeExpr,
706 },
707}
708
709#[derive(Debug, Clone, PartialEq)]
711pub struct ImplBlock {
712 pub generics: Option<Generics>,
713 pub trait_: Option<TypePath>,
714 pub self_ty: TypeExpr,
715 pub items: Vec<ImplItem>,
716}
717
718#[derive(Debug, Clone, PartialEq)]
719pub enum ImplItem {
720 Function(Function),
721 Type(TypeAlias),
722 Const(ConstDef),
723}
724
725#[derive(Debug, Clone, PartialEq)]
727pub struct TypeAlias {
728 pub visibility: Visibility,
729 pub name: Ident,
730 pub generics: Option<Generics>,
731 pub ty: TypeExpr,
732}
733
734#[derive(Debug, Clone, PartialEq)]
736pub struct Module {
737 pub visibility: Visibility,
738 pub name: Ident,
739 pub items: Option<Vec<Spanned<Item>>>,
740}
741
742#[derive(Debug, Clone, PartialEq)]
744pub struct UseDecl {
745 pub visibility: Visibility,
746 pub tree: UseTree,
747}
748
749#[derive(Debug, Clone, PartialEq)]
750pub enum UseTree {
751 Path {
752 prefix: Ident,
753 suffix: Box<UseTree>,
754 },
755 Name(Ident),
756 Rename {
757 name: Ident,
758 alias: Ident,
759 },
760 Glob,
761 Group(Vec<UseTree>),
762}
763
764#[derive(Debug, Clone, PartialEq)]
766pub struct ConstDef {
767 pub visibility: Visibility,
768 pub name: Ident,
769 pub ty: TypeExpr,
770 pub value: Expr,
771}
772
773#[derive(Debug, Clone, PartialEq)]
775pub struct StaticDef {
776 pub visibility: Visibility,
777 pub mutable: bool,
778 pub name: Ident,
779 pub ty: TypeExpr,
780 pub value: Expr,
781}
782
783#[derive(Debug, Clone, PartialEq)]
785pub struct ActorDef {
786 pub visibility: Visibility,
787 pub name: Ident,
788 pub generics: Option<Generics>,
789 pub state: Vec<FieldDef>,
790 pub handlers: Vec<MessageHandler>,
791}
792
793#[derive(Debug, Clone, PartialEq)]
794pub struct MessageHandler {
795 pub message: Ident,
796 pub params: Vec<Param>,
797 pub return_type: Option<TypeExpr>,
798 pub body: Block,
799}
800
801#[derive(Debug, Clone, PartialEq)]
803pub struct Block {
804 pub stmts: Vec<Stmt>,
805 pub expr: Option<Box<Expr>>,
806}
807
808#[derive(Debug, Clone, PartialEq)]
810pub enum Stmt {
811 Let {
812 pattern: Pattern,
813 ty: Option<TypeExpr>,
814 init: Option<Expr>,
815 },
816 Expr(Expr),
817 Semi(Expr),
818 Item(Box<Item>),
819}
820
821#[derive(Debug, Clone, PartialEq)]
823pub enum Pattern {
824 Ident {
825 mutable: bool,
826 name: Ident,
827 evidentiality: Option<Evidentiality>,
828 },
829 Tuple(Vec<Pattern>),
830 Struct {
831 path: TypePath,
832 fields: Vec<FieldPattern>,
833 rest: bool,
834 },
835 TupleStruct {
836 path: TypePath,
837 fields: Vec<Pattern>,
838 },
839 Slice(Vec<Pattern>),
840 Or(Vec<Pattern>),
841 Literal(Literal),
842 Range {
843 start: Option<Box<Pattern>>,
844 end: Option<Box<Pattern>>,
845 inclusive: bool,
846 },
847 Wildcard,
848 Rest,
849}
850
851#[derive(Debug, Clone, PartialEq)]
852pub struct FieldPattern {
853 pub name: Ident,
854 pub pattern: Option<Pattern>,
855}
856
857#[derive(Debug, Clone, PartialEq)]
859pub enum Expr {
860 Literal(Literal),
862 Path(TypePath),
864 Binary {
866 left: Box<Expr>,
867 op: BinOp,
868 right: Box<Expr>,
869 },
870 Unary {
872 op: UnaryOp,
873 expr: Box<Expr>,
874 },
875 Pipe {
877 expr: Box<Expr>,
878 operations: Vec<PipeOp>,
879 },
880 Incorporation {
882 segments: Vec<IncorporationSegment>,
883 },
884 Morpheme {
886 kind: MorphemeKind,
887 body: Box<Expr>,
888 },
889 Call {
891 func: Box<Expr>,
892 args: Vec<Expr>,
893 },
894 MethodCall {
896 receiver: Box<Expr>,
897 method: Ident,
898 args: Vec<Expr>,
899 },
900 Field {
902 expr: Box<Expr>,
903 field: Ident,
904 },
905 Index {
907 expr: Box<Expr>,
908 index: Box<Expr>,
909 },
910 Array(Vec<Expr>),
912 Tuple(Vec<Expr>),
914 Struct {
916 path: TypePath,
917 fields: Vec<FieldInit>,
918 rest: Option<Box<Expr>>,
919 },
920 Block(Block),
922 If {
924 condition: Box<Expr>,
925 then_branch: Block,
926 else_branch: Option<Box<Expr>>,
927 },
928 Match {
930 expr: Box<Expr>,
931 arms: Vec<MatchArm>,
932 },
933 Loop(Block),
935 While {
937 condition: Box<Expr>,
938 body: Block,
939 },
940 For {
942 pattern: Pattern,
943 iter: Box<Expr>,
944 body: Block,
945 },
946 Closure {
948 params: Vec<ClosureParam>,
949 body: Box<Expr>,
950 },
951 Await(Box<Expr>),
953 Try(Box<Expr>),
955 Return(Option<Box<Expr>>),
957 Break(Option<Box<Expr>>),
959 Continue,
961 Range {
963 start: Option<Box<Expr>>,
964 end: Option<Box<Expr>>,
965 inclusive: bool,
966 },
967 Macro {
969 path: TypePath,
970 tokens: String,
971 },
972 Evidential {
974 expr: Box<Expr>,
975 evidentiality: Evidentiality,
976 },
977 Assign {
979 target: Box<Expr>,
980 value: Box<Expr>,
981 },
982 Unsafe(Block),
984 Deref(Box<Expr>),
986 AddrOf {
988 mutable: bool,
989 expr: Box<Expr>,
990 },
991 Cast {
993 expr: Box<Expr>,
994 ty: TypeExpr,
995 },
996
997 InlineAsm(InlineAsm),
999
1000 VolatileRead {
1002 ptr: Box<Expr>,
1003 ty: Option<TypeExpr>,
1004 },
1005
1006 VolatileWrite {
1008 ptr: Box<Expr>,
1009 value: Box<Expr>,
1010 ty: Option<TypeExpr>,
1011 },
1012
1013 SimdLiteral {
1019 elements: Vec<Expr>,
1020 ty: Option<TypeExpr>,
1021 },
1022
1023 SimdIntrinsic {
1025 op: SimdOp,
1026 args: Vec<Expr>,
1027 },
1028
1029 SimdShuffle {
1031 a: Box<Expr>,
1032 b: Box<Expr>,
1033 indices: Vec<u8>,
1034 },
1035
1036 SimdSplat {
1038 value: Box<Expr>,
1039 lanes: u8,
1040 },
1041
1042 SimdExtract {
1044 vector: Box<Expr>,
1045 index: u8,
1046 },
1047
1048 SimdInsert {
1050 vector: Box<Expr>,
1051 index: u8,
1052 value: Box<Expr>,
1053 },
1054
1055 AtomicOp {
1061 op: AtomicOp,
1062 ptr: Box<Expr>,
1063 value: Option<Box<Expr>>, expected: Option<Box<Expr>>, ordering: MemoryOrdering,
1066 failure_ordering: Option<MemoryOrdering>, },
1068
1069 AtomicFence {
1071 ordering: MemoryOrdering,
1072 },
1073
1074 HttpRequest {
1082 method: HttpMethod,
1083 url: Box<Expr>,
1084 headers: Vec<(Expr, Expr)>,
1085 body: Option<Box<Expr>>,
1086 timeout: Option<Box<Expr>>,
1087 },
1088
1089 GrpcCall {
1092 service: Box<Expr>,
1093 method: Box<Expr>,
1094 message: Option<Box<Expr>>,
1095 metadata: Vec<(Expr, Expr)>,
1096 timeout: Option<Box<Expr>>,
1097 },
1098
1099 WebSocketConnect {
1102 url: Box<Expr>,
1103 protocols: Vec<Expr>,
1104 headers: Vec<(Expr, Expr)>,
1105 },
1106
1107 WebSocketMessage {
1109 kind: WebSocketMessageKind,
1110 data: Box<Expr>,
1111 },
1112
1113 KafkaOp {
1115 kind: KafkaOpKind,
1116 topic: Box<Expr>,
1117 payload: Option<Box<Expr>>,
1118 key: Option<Box<Expr>>,
1119 partition: Option<Box<Expr>>,
1120 },
1121
1122 GraphQLOp {
1124 kind: GraphQLOpKind,
1125 document: Box<Expr>,
1126 variables: Option<Box<Expr>>,
1127 operation_name: Option<Box<Expr>>,
1128 },
1129
1130 ProtocolStream {
1133 protocol: ProtocolKind,
1134 source: Box<Expr>,
1135 config: Option<Box<Expr>>,
1136 },
1137}
1138
1139#[derive(Debug, Clone, PartialEq)]
1141pub struct InlineAsm {
1142 pub template: String,
1144 pub outputs: Vec<AsmOperand>,
1146 pub inputs: Vec<AsmOperand>,
1148 pub clobbers: Vec<String>,
1150 pub options: AsmOptions,
1152}
1153
1154#[derive(Debug, Clone, PartialEq)]
1156pub struct AsmOperand {
1157 pub constraint: String,
1159 pub expr: Expr,
1161 pub kind: AsmOperandKind,
1163 pub output: Option<Box<Expr>>,
1165}
1166
1167#[derive(Debug, Clone, PartialEq, Eq)]
1169pub enum AsmOperandKind {
1170 Input,
1172 Output,
1174 InOut,
1176}
1177
1178#[derive(Debug, Clone, PartialEq, Default)]
1180pub struct AsmOptions {
1181 pub volatile: bool,
1183 pub pure_asm: bool,
1185 pub nomem: bool,
1187 pub nostack: bool,
1189 pub preserves_flags: bool,
1191 pub readonly: bool,
1193 pub att_syntax: bool,
1195}
1196
1197#[derive(Debug, Clone, PartialEq)]
1199pub enum PipeOp {
1200 Transform(Box<Expr>),
1202 Filter(Box<Expr>),
1204 Sort(Option<Ident>),
1206 Reduce(Box<Expr>),
1208 Middle,
1210 Choice,
1212 Nth(Box<Expr>),
1214 Next,
1216 First,
1218 Last,
1220 Parallel(Box<PipeOp>),
1223 Gpu(Box<PipeOp>),
1226 Method {
1228 name: Ident,
1229 args: Vec<Expr>,
1230 },
1231 Await,
1233 Named {
1235 prefix: Vec<Ident>,
1236 body: Option<Box<Expr>>,
1237 },
1238
1239 Send(Box<Expr>),
1246
1247 Recv,
1250
1251 Stream(Box<Expr>),
1254
1255 Connect(Option<Box<Expr>>),
1257
1258 Close,
1260
1261 Header {
1263 name: Box<Expr>,
1264 value: Box<Expr>,
1265 },
1266
1267 Body(Box<Expr>),
1269
1270 Timeout(Box<Expr>),
1272
1273 Retry {
1275 count: Box<Expr>,
1276 strategy: Option<Box<Expr>>,
1277 },
1278}
1279
1280#[derive(Debug, Clone, PartialEq)]
1282pub struct IncorporationSegment {
1283 pub name: Ident,
1284 pub args: Option<Vec<Expr>>,
1285}
1286
1287#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1289pub enum MorphemeKind {
1290 Transform, Filter, Sort, Reduce, Lambda, Sum, Product, Middle, Choice, Nth, Next, First, Last, }
1304
1305#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1311pub enum HttpMethod {
1312 Get,
1313 Post,
1314 Put,
1315 Delete,
1316 Patch,
1317 Head,
1318 Options,
1319 Connect,
1320 Trace,
1321}
1322
1323impl std::fmt::Display for HttpMethod {
1324 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1325 match self {
1326 HttpMethod::Get => write!(f, "GET"),
1327 HttpMethod::Post => write!(f, "POST"),
1328 HttpMethod::Put => write!(f, "PUT"),
1329 HttpMethod::Delete => write!(f, "DELETE"),
1330 HttpMethod::Patch => write!(f, "PATCH"),
1331 HttpMethod::Head => write!(f, "HEAD"),
1332 HttpMethod::Options => write!(f, "OPTIONS"),
1333 HttpMethod::Connect => write!(f, "CONNECT"),
1334 HttpMethod::Trace => write!(f, "TRACE"),
1335 }
1336 }
1337}
1338
1339#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1341pub enum WebSocketMessageKind {
1342 Text,
1343 Binary,
1344 Ping,
1345 Pong,
1346 Close,
1347}
1348
1349#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1351pub enum KafkaOpKind {
1352 Produce,
1353 Consume,
1354 Subscribe,
1355 Unsubscribe,
1356 Commit,
1357 Seek,
1358}
1359
1360#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1362pub enum GraphQLOpKind {
1363 Query,
1364 Mutation,
1365 Subscription,
1366}
1367
1368#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1370pub enum ProtocolKind {
1371 Http,
1372 Grpc,
1373 WebSocket,
1374 Kafka,
1375 Amqp,
1376 GraphQL,
1377}
1378
1379impl std::fmt::Display for ProtocolKind {
1380 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1381 match self {
1382 ProtocolKind::Http => write!(f, "http"),
1383 ProtocolKind::Grpc => write!(f, "grpc"),
1384 ProtocolKind::WebSocket => write!(f, "ws"),
1385 ProtocolKind::Kafka => write!(f, "kafka"),
1386 ProtocolKind::Amqp => write!(f, "amqp"),
1387 ProtocolKind::GraphQL => write!(f, "graphql"),
1388 }
1389 }
1390}
1391
1392#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1394pub enum BinOp {
1395 Add,
1396 Sub,
1397 Mul,
1398 Div,
1399 Rem,
1400 Pow,
1401 And,
1402 Or,
1403 BitAnd,
1404 BitOr,
1405 BitXor,
1406 Shl,
1407 Shr,
1408 Eq,
1409 Ne,
1410 Lt,
1411 Le,
1412 Gt,
1413 Ge,
1414 Concat,
1415}
1416
1417#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1419pub enum UnaryOp {
1420 Neg,
1421 Not,
1422 Deref,
1423 Ref,
1424 RefMut,
1425}
1426
1427#[derive(Debug, Clone, PartialEq)]
1429pub enum Literal {
1430 Int {
1431 value: String,
1432 base: NumBase,
1433 suffix: Option<String>,
1434 },
1435 Float {
1436 value: String,
1437 suffix: Option<String>,
1438 },
1439 String(String),
1440 MultiLineString(String),
1442 RawString(String),
1444 ByteString(Vec<u8>),
1446 InterpolatedString {
1448 parts: Vec<InterpolationPart>,
1449 },
1450 SigilStringSql(String),
1452 SigilStringRoute(String),
1454 Char(char),
1455 Bool(bool),
1456 Null, Empty, Infinity, Circle, }
1462
1463#[derive(Debug, Clone, PartialEq)]
1465pub enum InterpolationPart {
1466 Text(String),
1468 Expr(Box<Expr>),
1470}
1471
1472#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1474pub enum NumBase {
1475 Binary, Octal, Decimal, Hex, Vigesimal, Sexagesimal, Duodecimal, Explicit(u8),}
1484
1485#[derive(Debug, Clone, PartialEq)]
1486pub struct FieldInit {
1487 pub name: Ident,
1488 pub value: Option<Expr>,
1489}
1490
1491#[derive(Debug, Clone, PartialEq)]
1492pub struct MatchArm {
1493 pub pattern: Pattern,
1494 pub guard: Option<Expr>,
1495 pub body: Expr,
1496}
1497
1498#[derive(Debug, Clone, PartialEq)]
1499pub struct ClosureParam {
1500 pub pattern: Pattern,
1501 pub ty: Option<TypeExpr>,
1502}