pub struct Context<'src> {
pub parts: Vec<Expr<'src>>,
/* private fields */
}Expand description
Represents a context in a GitHub Actions expression.
These typically look something like github.actor or inputs.foo,
although they can also be a “call” context like fromJSON(...).foo.bar,
i.e. where the head of the context is a function call rather than an
identifier.
Fields§
§parts: Vec<Expr<'src>>The individual parts of the context.
Implementations§
Source§impl<'src> Context<'src>
impl<'src> Context<'src>
Sourcepub fn child_of(&self, parent: impl TryInto<ContextPattern<'src>>) -> bool
pub fn child_of(&self, parent: impl TryInto<ContextPattern<'src>>) -> bool
Returns whether the context is a child of the given pattern.
A context is considered its own child, i.e. foo.bar is a child of
foo.bar.
Sourcepub fn pop_if(&self, head: &str) -> Option<&str>
pub fn pop_if(&self, head: &str) -> Option<&str>
Returns the tail of the context if the head matches the given string.
Sourcepub fn as_pattern(&self) -> Option<String>
pub fn as_pattern(&self) -> Option<String>
Returns the “pattern equivalent” of this context.
This is a string that can be used to efficiently match the context,
such as is done in zizmor’s template-injection audit via a
finite state transducer.
Returns None if the context doesn’t have a sensible pattern equivalent, e.g. if it starts with a call.
Trait Implementations§
Auto Trait Implementations§
impl<'src> Freeze for Context<'src>
impl<'src> RefUnwindSafe for Context<'src>
impl<'src> Send for Context<'src>
impl<'src> Sync for Context<'src>
impl<'src> Unpin for Context<'src>
impl<'src> UnwindSafe for Context<'src>
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> 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