@@ -19,14 +19,16 @@ pub struct ParsedExpr {
1919/// operators with the exception of the '.' operator are modelled as function
2020/// calls. This makes it easy to represent new operators into the existing AST.
2121///
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.
2627///
2728/// 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`.
3032#[ allow( clippy:: derive_partial_eq_without_eq) ]
3133#[ derive( Clone , PartialEq , :: prost:: Message ) ]
3234pub struct Expr {
@@ -48,7 +50,8 @@ pub mod expr {
4850 /// Required. Holds a single, unqualified identifier, possibly preceded by a
4951 /// '.'.
5052 ///
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.
5255 #[ prost( string, tag="1" ) ]
5356 pub name : :: prost:: alloc:: string:: String ,
5457 }
@@ -260,7 +263,8 @@ pub mod expr {
260263/// primitives.
261264///
262265/// 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.
264268///
265269/// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
266270/// `true`, `null`.
@@ -346,6 +350,91 @@ pub struct SourceInfo {
346350 /// value is the call `Expr` that was replaced.
347351 #[ prost( map="int64, message" , tag="5" ) ]
348352 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+ }
349438}
350439/// A specific position in source.
351440#[ allow( clippy:: derive_partial_eq_without_eq) ]
0 commit comments