#[non_exhaustive]pub enum ToASTErrorKind {
Show 55 variants
DuplicateTemplateId(PolicyID),
DuplicatePolicyId(PolicyID),
ExpectedStaticPolicy(ExpectedStaticPolicy),
ExpectedTemplate(ExpectedTemplate),
DuplicateAnnotation(AnyId),
SlotsInConditionClause(SlotsInConditionClause),
MissingScopeVariable(Var),
ExtraScopeElement(VariableDef),
ReservedIdentifier(Ident),
InvalidIdentifier(String),
InvalidSingleEq,
InvalidEffect(Ident),
InvalidCondition(Ident),
InvalidScopeVariable(Ident),
IncorrectVariable {
expected: Var,
got: Var,
},
InvalidScopeOperator(RelOp),
InvalidActionScopeOperator(RelOp),
IsInActionScope,
IsWithEq,
InvalidActionType(InvalidActionType),
EmptyClause(Option<Ident>),
MembershipInvariantViolation,
InvalidString(String),
ArbitraryVariable(SmolStr),
InvalidAttribute(SmolStr),
PathAsAttribute(String),
FunctionCallOnMethod(UnreservedId),
MethodCallOnFunction(UnreservedId),
InvalidPattern(String),
InvalidIsType(String),
WrongNode {
expected: &'static str,
got: String,
suggestion: Option<String>,
},
AmbiguousOperators,
UnsupportedDivision,
UnsupportedModulo,
ExpressionConstructionError(ExpressionConstructionError),
IntegerLiteralTooLarge(u64),
UnaryOpLimit(UnaryOp),
VariableCall(Var),
NoMethods(Name, UnreservedId),
UnknownMethod {
id: UnreservedId,
hint: Option<String>,
},
UnknownFunction {
id: Name,
hint: Option<String>,
},
InvalidEntityLiteral(String),
ExpressionCall,
InvalidAccess(Name, SmolStr),
InvalidIndex(Name, SmolStr),
NonStringIndex,
TypeConstraints,
NonNormalizedString {
kind: &'static str,
src: String,
normalized_src: String,
},
EmptyNodeInvariantViolation,
WrongArity {
name: &'static str,
expected: usize,
got: usize,
},
Unescape(UnescapeError),
WrongEntityArgument(WrongEntityArgument),
InvalidSlot(SmolStr),
ReservedNamespace(ReservedNameError),
InvertedIsIn,
}
Expand description
Details about a particular kind of ToASTError
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DuplicateTemplateId(PolicyID)
Returned when we attempt to parse a template with a conflicting id
DuplicatePolicyId(PolicyID)
Returned when we attempt to parse a policy with a conflicting id
ExpectedStaticPolicy(ExpectedStaticPolicy)
Returned when a template is encountered but a static policy is expected
ExpectedTemplate(ExpectedTemplate)
Returned when a static policy is encountered but a template is expected
DuplicateAnnotation(AnyId)
Returned when we attempt to parse a policy or template with duplicate or conflicting annotations
SlotsInConditionClause(SlotsInConditionClause)
Returned when a policy contains template slots in a when/unless clause. This is not currently supported; see RFC 3.
MissingScopeVariable(Var)
Returned when a policy is missing one of the three required scope elements
(principal
, action
, and resource
)
ExtraScopeElement(VariableDef)
Returned when a policy has an extra scope element
ReservedIdentifier(Ident)
Returned when a policy uses a reserved keyword as an identifier.
InvalidIdentifier(String)
Returned when a policy contains an invalid identifier.
This error is not currently returned, but is here for future-proofing;
see cst::Ident::Invalid
.
InvalidSingleEq
Returned when a policy uses ‘=’ as a binary operator. ‘=’ is not an operator in Cedar; we can suggest ‘==’ instead.
InvalidEffect(Ident)
Returned when a policy uses an effect keyword beyond permit
or forbid
InvalidCondition(Ident)
Returned when a policy uses a condition keyword beyond when
or unless
InvalidScopeVariable(Ident)
Returned when a policy uses a variable in the scope beyond principal
,
action
, or resource
IncorrectVariable
Returned when a policy scope clause contains the wrong variable.
(principal
must be in the first clause, etc…)
InvalidScopeOperator(RelOp)
Returned when a policy scope uses an operator not allowed in scopes
InvalidActionScopeOperator(RelOp)
Returned when an action scope uses an operator not allowed in action scopes
(special case of InvalidScopeOperator
)
IsInActionScope
Returned when the action scope clause contains an is
IsWithEq
Returned when an is
operator is used together with ==
InvalidActionType(InvalidActionType)
Returned when an entity uid used as an action does not have the type Action
EmptyClause(Option<Ident>)
Returned when a condition clause is empty
MembershipInvariantViolation
Returned when membership chains do not resolve to an expression, violating an internal invariant
InvalidString(String)
Returned for a non-parse-able string literal
ArbitraryVariable(SmolStr)
Returned when attempting to use an arbitrary variable name. Cedar does not support arbitrary variables.
InvalidAttribute(SmolStr)
Returned when attempting to use an invalid attribute name
PathAsAttribute(String)
Returned when attempting to use an attribute with a namespace
FunctionCallOnMethod(UnreservedId)
Returned when a policy attempts to call a method function-style
MethodCallOnFunction(UnreservedId)
Returned when a policy attempts to call a function in the method style
InvalidPattern(String)
Returned when the right hand side of a like
expression is not a constant pattern literal
InvalidIsType(String)
Returned when the right hand side of a is
expression is not an entity type name
WrongNode
Returned when an unexpected node is in the policy scope
Fields
AmbiguousOperators
Returned when a policy contains ambiguous ordering of operators. This can be resolved by using parenthesis to make order explicit
UnsupportedDivision
Returned when a policy uses the division operator (/
), which is not supported
UnsupportedModulo
Returned when a policy uses the remainder/modulo operator (%
), which is not supported
ExpressionConstructionError(ExpressionConstructionError)
Any ExpressionConstructionError
can also happen while converting CST to AST
IntegerLiteralTooLarge(u64)
Returned when a policy contains an integer literal that is out of range
UnaryOpLimit(UnaryOp)
Returned when a unary operator is chained more than 4 times in a row
VariableCall(Var)
Returned when a variable is called as a function, which is not allowed. Functions are not first class values in Cedar
NoMethods(Name, UnreservedId)
Returned when a policy attempts to call a method on a value that has no methods
UnknownMethod
Returned when a policy attempts to call a method that does not exist
Fields
id: UnreservedId
The user-provided method id
UnknownFunction
Returned when a policy attempts to call a function that does not exist
InvalidEntityLiteral(String)
Returned when a policy attempts to write an entity literal
ExpressionCall
Returned when an expression is the target of a function call. Functions are not first class values in Cedar
InvalidAccess(Name, SmolStr)
Returned when a policy attempts to access the fields of a value with no fields
InvalidIndex(Name, SmolStr)
Returned when a policy attempts to index on a fields of a value with no fields
NonStringIndex
Returned when the contents of an indexing expression is not a string literal
TypeConstraints
Returned when a user attempts to use type-constraint :
syntax. This
syntax was not adopted, but is
can be used to write type constraints
in the policy scope.
NonNormalizedString
Returned when a string needs to be fully normalized
Fields
EmptyNodeInvariantViolation
Returned when a CST node is empty during CST to AST/EST conversion. This should have resulted in an error during the text to CST conversion, which will terminate parsing. So it should be unreachable in later stages.
WrongArity
Returned when a function or method is called with the wrong arity
Fields
Unescape(UnescapeError)
Returned when a string contains invalid escapes
WrongEntityArgument(WrongEntityArgument)
Returned when a policy scope has incorrect entity uids or template slots
InvalidSlot(SmolStr)
Returned when a policy contains a template slot other than ?principal
or ?resource
ReservedNamespace(ReservedNameError)
Returned when an entity type contains a reserved namespace or typename (as of this writing, just __cedar
)
InvertedIsIn
Returned when a policy uses _ in _ is _
instead of _ is _ in _
in the policy scope
Implementations§
Source§impl ToASTErrorKind
impl ToASTErrorKind
Sourcepub fn wrong_node(
expected: &'static str,
got: impl Into<String>,
suggestion: Option<impl Into<String>>,
) -> Self
pub fn wrong_node( expected: &'static str, got: impl Into<String>, suggestion: Option<impl Into<String>>, ) -> Self
Constructor for the ToASTErrorKind::WrongNode
error
Sourcepub fn wrong_arity(name: &'static str, expected: usize, got: usize) -> Self
pub fn wrong_arity(name: &'static str, expected: usize, got: usize) -> Self
Constructor for the ToASTErrorKind::WrongArity
error
Sourcepub fn slots_in_condition_clause(slot: Slot, clause_type: &'static str) -> Self
pub fn slots_in_condition_clause(slot: Slot, clause_type: &'static str) -> Self
Constructor for the ToASTErrorKind::SlotsInConditionClause
error
Sourcepub fn expected_static_policy(slot: Slot) -> Self
pub fn expected_static_policy(slot: Slot) -> Self
Constructor for the ToASTErrorKind::ExpectedStaticPolicy
error
Sourcepub fn expected_template() -> Self
pub fn expected_template() -> Self
Constructor for the ToASTErrorKind::ExpectedTemplate
error
Sourcepub fn wrong_entity_argument_one_expected(expected: Ref, got: Ref) -> Self
pub fn wrong_entity_argument_one_expected(expected: Ref, got: Ref) -> Self
Constructor for the ToASTErrorKind::WrongEntityArgument
error when
one kind of entity argument was expected
Sourcepub fn wrong_entity_argument_two_expected(r1: Ref, r2: Ref, got: Ref) -> Self
pub fn wrong_entity_argument_two_expected(r1: Ref, r2: Ref, got: Ref) -> Self
Constructor for the ToASTErrorKind::WrongEntityArgument
error when
one of two kinds of entity argument was expected
Trait Implementations§
Source§impl Clone for ToASTErrorKind
impl Clone for ToASTErrorKind
Source§fn clone(&self) -> ToASTErrorKind
fn clone(&self) -> ToASTErrorKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ToASTErrorKind
impl Debug for ToASTErrorKind
Source§impl Diagnostic for ToASTErrorKind
impl Diagnostic for ToASTErrorKind
Source§fn code(&self) -> Option<Box<dyn Display + '_>>
fn code(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz
) is recommended, but more classic codes like
E0123
or enums will work just fine.Source§fn help(&self) -> Option<Box<dyn Display + '_>>
fn help(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandler
s to change the display format
of this diagnostic. Read moreSource§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic
’s Diagnostic::source_code
Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic
’s Diagnostic::labels
to.Diagnostic
s.Source§fn url(&self) -> Option<Box<dyn Display + '_>>
fn url(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
.Source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§impl Display for ToASTErrorKind
impl Display for ToASTErrorKind
Source§impl Error for ToASTErrorKind
impl Error for ToASTErrorKind
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ExpectedStaticPolicy> for ToASTErrorKind
impl From<ExpectedStaticPolicy> for ToASTErrorKind
Source§fn from(source: ExpectedStaticPolicy) -> Self
fn from(source: ExpectedStaticPolicy) -> Self
Source§impl From<ExpectedTemplate> for ToASTErrorKind
impl From<ExpectedTemplate> for ToASTErrorKind
Source§fn from(source: ExpectedTemplate) -> Self
fn from(source: ExpectedTemplate) -> Self
Source§impl From<ExpressionConstructionError> for ToASTErrorKind
impl From<ExpressionConstructionError> for ToASTErrorKind
Source§fn from(source: ExpressionConstructionError) -> Self
fn from(source: ExpressionConstructionError) -> Self
Source§impl From<InvalidActionType> for ToASTErrorKind
impl From<InvalidActionType> for ToASTErrorKind
Source§fn from(source: InvalidActionType) -> Self
fn from(source: InvalidActionType) -> Self
Source§impl From<ReservedNameError> for ToASTErrorKind
impl From<ReservedNameError> for ToASTErrorKind
Source§fn from(source: ReservedNameError) -> Self
fn from(source: ReservedNameError) -> Self
Source§impl From<SlotsInConditionClause> for ToASTErrorKind
impl From<SlotsInConditionClause> for ToASTErrorKind
Source§fn from(source: SlotsInConditionClause) -> Self
fn from(source: SlotsInConditionClause) -> Self
Source§impl From<UnescapeError> for ToASTErrorKind
impl From<UnescapeError> for ToASTErrorKind
Source§fn from(source: UnescapeError) -> Self
fn from(source: UnescapeError) -> Self
Source§impl From<WrongEntityArgument> for ToASTErrorKind
impl From<WrongEntityArgument> for ToASTErrorKind
Source§fn from(source: WrongEntityArgument) -> Self
fn from(source: WrongEntityArgument) -> Self
Source§impl PartialEq for ToASTErrorKind
impl PartialEq for ToASTErrorKind
impl Eq for ToASTErrorKind
impl StructuralPartialEq for ToASTErrorKind
Auto Trait Implementations§
impl Freeze for ToASTErrorKind
impl RefUnwindSafe for ToASTErrorKind
impl Send for ToASTErrorKind
impl Sync for ToASTErrorKind
impl Unpin for ToASTErrorKind
impl UnwindSafe for ToASTErrorKind
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more