pub struct CompiledGlob { /* private fields */ }Expand description
One compiled glob plus the bookkeeping the precedence rule needs.
Why: literal_prefix_len is computed once at parse time because the
“longest literal prefix wins” comparison runs on every tool call, and the
pattern text is kept because a refusal reports it back (“denied by policy
(bash[rm *])”) — a compiled GlobMatcher cannot be printed.
What: * deliberately spans / (globset’s default) so rm * matches
rm -rf /tmp/x.
Test: literal_prefix_stops_at_the_first_metacharacter.
Implementations§
Source§impl CompiledGlob
impl CompiledGlob
Sourcepub fn compile(pattern: &str) -> Result<Self, String>
pub fn compile(pattern: &str) -> Result<Self, String>
Compile pattern, or report why it is not a usable glob.
pub because crate::permissions::session also compiles the pattern a
client attaches to an allow_for_session grant.
Test: bad_glob_is_rejected.
Sourcepub fn literal_prefix_len(&self) -> usize
pub fn literal_prefix_len(&self) -> usize
How many leading characters of the pattern are literal.
Trait Implementations§
Source§impl Clone for CompiledGlob
impl Clone for CompiledGlob
Auto Trait Implementations§
impl Freeze for CompiledGlob
impl RefUnwindSafe for CompiledGlob
impl Send for CompiledGlob
impl Sync for CompiledGlob
impl Unpin for CompiledGlob
impl UnsafeUnpin for CompiledGlob
impl UnwindSafe for CompiledGlob
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.