@@ -19,14 +19,16 @@ pub struct ParsedExpr {
19
19
/// operators with the exception of the '.' operator are modelled as function
20
20
/// calls. This makes it easy to represent new operators into the existing AST.
21
21
///
22
- /// All references within expressions must resolve to a \[Decl][google.api.expr.v1alpha1.Decl\] provided at
23
- /// type-check for an expression to be valid. A reference may either be a bare
24
- /// identifier `name` or a qualified identifier `google.api.name`. References
25
- /// may either refer to a value or a function declaration.
22
+ /// All references within expressions must resolve to a
23
+ /// \[Decl][google.api.expr.v1alpha1.Decl\] provided at type-check for an
24
+ /// expression to be valid. A reference may either be a bare identifier `name` or
25
+ /// a qualified identifier `google.api.name`. References may either refer to a
26
+ /// value or a function declaration.
26
27
///
27
28
/// For example, the expression `google.api.name.startsWith('expr')` references
28
- /// the declaration `google.api.name` within a \[Expr.Select][google.api.expr.v1alpha1.Expr.Select\] expression, and
29
- /// the function declaration `startsWith`.
29
+ /// the declaration `google.api.name` within a
30
+ /// \[Expr.Select][google.api.expr.v1alpha1.Expr.Select\] expression, and the
31
+ /// function declaration `startsWith`.
30
32
#[ allow( clippy:: derive_partial_eq_without_eq) ]
31
33
#[ derive( Clone , PartialEq , :: prost:: Message ) ]
32
34
pub struct Expr {
@@ -48,7 +50,8 @@ pub mod expr {
48
50
/// Required. Holds a single, unqualified identifier, possibly preceded by a
49
51
/// '.'.
50
52
///
51
- /// Qualified names are represented by the \[Expr.Select][google.api.expr.v1alpha1.Expr.Select\] expression.
53
+ /// Qualified names are represented by the
54
+ /// \[Expr.Select][google.api.expr.v1alpha1.Expr.Select\] expression.
52
55
#[ prost( string, tag="1" ) ]
53
56
pub name : :: prost:: alloc:: string:: String ,
54
57
}
@@ -260,7 +263,8 @@ pub mod expr {
260
263
/// primitives.
261
264
///
262
265
/// Lists and structs are not included as constants as these aggregate types may
263
- /// contain \[Expr][google.api.expr.v1alpha1.Expr\] elements which require evaluation and are thus not constant.
266
+ /// contain \[Expr][google.api.expr.v1alpha1.Expr\] elements which require
267
+ /// evaluation and are thus not constant.
264
268
///
265
269
/// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
266
270
/// `true`, `null`.
@@ -346,6 +350,91 @@ pub struct SourceInfo {
346
350
/// value is the call `Expr` that was replaced.
347
351
#[ prost( map="int64, message" , tag="5" ) ]
348
352
pub macro_calls : :: std:: collections:: HashMap < i64 , Expr > ,
353
+ /// A list of tags for extensions that were used while parsing or type checking
354
+ /// the source expression. For example, optimizations that require special
355
+ /// runtime support may be specified.
356
+ ///
357
+ /// These are used to check feature support between components in separate
358
+ /// implementations. This can be used to either skip redundant work or
359
+ /// report an error if the extension is unsupported.
360
+ #[ prost( message, repeated, tag="6" ) ]
361
+ pub extensions : :: prost:: alloc:: vec:: Vec < source_info:: Extension > ,
362
+ }
363
+ /// Nested message and enum types in `SourceInfo`.
364
+ pub mod source_info {
365
+ /// An extension that was requested for the source expression.
366
+ #[ allow( clippy:: derive_partial_eq_without_eq) ]
367
+ #[ derive( Clone , PartialEq , :: prost:: Message ) ]
368
+ pub struct Extension {
369
+ /// Identifier for the extension. Example: constant_folding
370
+ #[ prost( string, tag="1" ) ]
371
+ pub id : :: prost:: alloc:: string:: String ,
372
+ /// If set, the listed components must understand the extension for the
373
+ /// expression to evaluate correctly.
374
+ ///
375
+ /// This field has set semantics, repeated values should be deduplicated.
376
+ #[ prost( enumeration="extension::Component" , repeated, tag="2" ) ]
377
+ pub affected_components : :: prost:: alloc:: vec:: Vec < i32 > ,
378
+ /// Version info. May be skipped if it isn't meaningful for the extension.
379
+ /// (for example constant_folding might always be v0.0).
380
+ #[ prost( message, optional, tag="3" ) ]
381
+ pub version : :: core:: option:: Option < extension:: Version > ,
382
+ }
383
+ /// Nested message and enum types in `Extension`.
384
+ pub mod extension {
385
+ /// Version
386
+ #[ allow( clippy:: derive_partial_eq_without_eq) ]
387
+ #[ derive( Clone , PartialEq , :: prost:: Message ) ]
388
+ pub struct Version {
389
+ /// Major version changes indicate different required support level from
390
+ /// the required components.
391
+ #[ prost( int64, tag="1" ) ]
392
+ pub major : i64 ,
393
+ /// Minor version changes must not change the observed behavior from
394
+ /// existing implementations, but may be provided informationally.
395
+ #[ prost( int64, tag="2" ) ]
396
+ pub minor : i64 ,
397
+ }
398
+ /// CEL component specifier.
399
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , PartialOrd , Ord , :: prost:: Enumeration ) ]
400
+ #[ repr( i32 ) ]
401
+ pub enum Component {
402
+ /// Unspecified, default.
403
+ Unspecified = 0 ,
404
+ /// Parser. Converts a CEL string to an AST.
405
+ Parser = 1 ,
406
+ /// Type checker. Checks that references in an AST are defined and types
407
+ /// agree.
408
+ TypeChecker = 2 ,
409
+ /// Runtime. Evaluates a parsed and optionally checked CEL AST against a
410
+ /// context.
411
+ Runtime = 3 ,
412
+ }
413
+ impl Component {
414
+ /// String value of the enum field names used in the ProtoBuf definition.
415
+ ///
416
+ /// The values are not transformed in any way and thus are considered stable
417
+ /// (if the ProtoBuf definition does not change) and safe for programmatic use.
418
+ pub fn as_str_name ( & self ) -> & ' static str {
419
+ match self {
420
+ Component :: Unspecified => "COMPONENT_UNSPECIFIED" ,
421
+ Component :: Parser => "COMPONENT_PARSER" ,
422
+ Component :: TypeChecker => "COMPONENT_TYPE_CHECKER" ,
423
+ Component :: Runtime => "COMPONENT_RUNTIME" ,
424
+ }
425
+ }
426
+ /// Creates an enum from field names used in the ProtoBuf definition.
427
+ pub fn from_str_name ( value : & str ) -> :: core:: option:: Option < Self > {
428
+ match value {
429
+ "COMPONENT_UNSPECIFIED" => Some ( Self :: Unspecified ) ,
430
+ "COMPONENT_PARSER" => Some ( Self :: Parser ) ,
431
+ "COMPONENT_TYPE_CHECKER" => Some ( Self :: TypeChecker ) ,
432
+ "COMPONENT_RUNTIME" => Some ( Self :: Runtime ) ,
433
+ _ => None ,
434
+ }
435
+ }
436
+ }
437
+ }
349
438
}
350
439
/// A specific position in source.
351
440
#[ allow( clippy:: derive_partial_eq_without_eq) ]
0 commit comments