pub struct RulesFile<'a> { /* private fields */ }Expand description
A parsed lean-ctx rules section from a file on disk.
Handles version detection, content boundary discovery, and prefix/suffix
extraction. This is the only place that parses START_MARK / version
comments — every consumer (injection, drift detection, status reporting)
goes through this struct.
Implementations§
Source§impl<'a> RulesFile<'a>
impl<'a> RulesFile<'a>
Sourcepub fn parse(content: &'a str) -> Self
pub fn parse(content: &'a str) -> Self
Parse content, scanning for START_MARK and version comment.
START_MARKnot found →has_content() = false, version = 0.START_MARKfound but no version →has_content() = true, version = 0 (assume older than current → needs update).
Sourcepub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Whether the file carries any lean-ctx rules content.
Sourcepub fn version(&self) -> usize
pub fn version(&self) -> usize
The detected version (0 if no version marker — treat as older than
RULES_VERSION).
Sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Whether the file’s version is at least RULES_VERSION.
Sourcepub fn prefix(&self) -> &'a str
pub fn prefix(&self) -> &'a str
Content before the first START_MARK (user content / frontmatter).
Returns an empty string if no start marker was found.
Sourcepub fn suffix(&self) -> &'a str
pub fn suffix(&self) -> &'a str
Content after the last END_MARK (user content after the lean-ctx
block). Returns an empty string if no end marker was found.
Sourcepub fn merged(
&self,
shadow: bool,
wrapper: Wrapper,
level: CompressionLevel,
) -> String
pub fn merged( &self, shadow: bool, wrapper: Wrapper, level: CompressionLevel, ) -> String
Merge freshly-rendered rules into this file.
- If a lean-ctx section exists → replaces content between
START_MARKandEND_MARK, preserving user content before/after. - If no section exists → appends fresh content at the end.
Sourcepub fn initial(
shadow: bool,
wrapper: Wrapper,
level: CompressionLevel,
) -> String
pub fn initial( shadow: bool, wrapper: Wrapper, level: CompressionLevel, ) -> String
Create initial rules content (no existing section to merge with).
Sourcepub fn without_section(&self) -> String
pub fn without_section(&self) -> String
Strip the lean-ctx section, keeping only user content before/after.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RulesFile<'a>
impl<'a> RefUnwindSafe for RulesFile<'a>
impl<'a> Send for RulesFile<'a>
impl<'a> Sync for RulesFile<'a>
impl<'a> Unpin for RulesFile<'a>
impl<'a> UnsafeUnpin for RulesFile<'a>
impl<'a> UnwindSafe for RulesFile<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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