pub struct LineInFileBlockExpectedState { /* private fields */ }Expand description
Configuration for managing a line in a file
Implementations§
Source§impl LineInFileBlockExpectedState
impl LineInFileBlockExpectedState
Sourcepub fn absent(
file_path: &str,
line: Line,
file_must_exist_anyway: bool,
) -> LineInFileBlockExpectedState
pub fn absent( file_path: &str, line: Line, file_must_exist_anyway: bool, ) -> LineInFileBlockExpectedState
Creates a block for a line that should not exist in the file.
file_path: Path to the file.line: The line (or pattern) to ensure is absent.file_must_exist_anyway: Iftrue, the file must exist (but the line must not). Iffalse, the file may not exist (and the line is trivially absent).
Sourcepub fn present_at_top(
file_path: &str,
line: Line,
create: Option<bool>,
) -> LineInFileBlockExpectedState
pub fn present_at_top( file_path: &str, line: Line, create: Option<bool>, ) -> LineInFileBlockExpectedState
Creates a block for a line that should exist at the top of the file.
file_path: Path to the file.line: The line to insert (or ensure exists).create: Iftrue, the file will be created if it doesn’t exist.
Sourcepub fn present_at_bottom(
file_path: &str,
line: Line,
create: Option<bool>,
) -> LineInFileBlockExpectedState
pub fn present_at_bottom( file_path: &str, line: Line, create: Option<bool>, ) -> LineInFileBlockExpectedState
Creates a block for a line that should exist at the bottom of the file.
file_path: Path to the file.line: The line to insert (or ensure exists).create: Iftrue, the file will be created if it doesn’t exist.
Sourcepub fn present_after(
file_path: &str,
line: Line,
insert_after: &str,
firstmatch: Option<bool>,
create: Option<bool>,
) -> LineInFileBlockExpectedState
pub fn present_after( file_path: &str, line: Line, insert_after: &str, firstmatch: Option<bool>, create: Option<bool>, ) -> LineInFileBlockExpectedState
Creates a block for a line that should exist after a specific pattern.
file_path: Path to the file.line: The line to insert (or ensure exists).insert_after: The pattern to match (e.g., a regex or literal string).firstmatch: Iftrue, use the first match ofinsert_after. Iffalse, use the last match.create: Iftrue, the file will be created if it doesn’t exist.
Sourcepub fn present_before(
file_path: &str,
line: Line,
insert_before: &str,
firstmatch: Option<bool>,
create: Option<bool>,
) -> LineInFileBlockExpectedState
pub fn present_before( file_path: &str, line: Line, insert_before: &str, firstmatch: Option<bool>, create: Option<bool>, ) -> LineInFileBlockExpectedState
Creates a block for a line that should exist before a specific pattern.
file_path: Path to the file.line: The line to insert (or ensure exists).insert_before: The pattern to match (e.g., a regex or literal string).firstmatch: Iftrue, use the first match ofinsert_before. Iffalse, use the last match.create: Iftrue, the file will be created if it doesn’t exist.
Sourcepub fn present_anywhere(
file_path: &str,
line: Line,
create: Option<bool>,
) -> LineInFileBlockExpectedState
pub fn present_anywhere( file_path: &str, line: Line, create: Option<bool>, ) -> LineInFileBlockExpectedState
Creates a block for a line that should exist somewhere in the file (no position constraint).
file_path: Path to the file.line: The line to ensure exists.create: Iftrue, the file will be created if it doesn’t exist.
Sourcepub fn raw_line(content: Parameter<String>) -> Line
pub fn raw_line(content: Parameter<String>) -> Line
Helper to create a Line::Raw from a string.
Sourcepub fn regexp_line(pattern: &str) -> Line
pub fn regexp_line(pattern: &str) -> Line
Helper to create a Line::Regexp from a regex pattern.
Sourcepub fn regexp_with_backrefs_line(regexp: &str, content_to_insert: &str) -> Line
pub fn regexp_with_backrefs_line(regexp: &str, content_to_insert: &str) -> Line
Helper to create a Line::RegexpWithBackrefs from a regex and replacement.
Sourcepub fn search_string_line(pattern: &str) -> Line
pub fn search_string_line(pattern: &str) -> Line
Helper to create a Line::SearchString from a literal string.
Trait Implementations§
Source§impl<Handler: HostHandler> AssessCompliance<Handler> for LineInFileBlockExpectedState
impl<Handler: HostHandler> AssessCompliance<Handler> for LineInFileBlockExpectedState
Source§async fn assess_compliance(
&self,
host_handler: &mut Handler,
host_properties: &Option<HostProperties>,
privilege: &Privilege,
optional_secret_provider: &Option<SecretProvidersPool>,
) -> Result<AttributeComplianceAssessment, RegentError>
async fn assess_compliance( &self, host_handler: &mut Handler, host_properties: &Option<HostProperties>, privilege: &Privilege, optional_secret_provider: &Option<SecretProvidersPool>, ) -> Result<AttributeComplianceAssessment, RegentError>
Assess whether the host is compliant. Read more
Source§impl Check for LineInFileBlockExpectedState
impl Check for LineInFileBlockExpectedState
Source§fn check_host_compatibility(
&self,
_host_properties: &HostProperties,
) -> Result<(), RegentError>
fn check_host_compatibility( &self, _host_properties: &HostProperties, ) -> Result<(), RegentError>
If host properties are known, checks whether this attribute is compatible with the host or not. Read more
Source§impl Clone for LineInFileBlockExpectedState
impl Clone for LineInFileBlockExpectedState
Source§fn clone(&self) -> LineInFileBlockExpectedState
fn clone(&self) -> LineInFileBlockExpectedState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LineInFileBlockExpectedState
impl Debug for LineInFileBlockExpectedState
Source§impl<'de> Deserialize<'de> for LineInFileBlockExpectedState
impl<'de> Deserialize<'de> for LineInFileBlockExpectedState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for LineInFileBlockExpectedState
Source§impl Timeout for LineInFileBlockExpectedState
impl Timeout for LineInFileBlockExpectedState
Source§fn default_timeout(&self) -> Duration
fn default_timeout(&self) -> Duration
Get the default timeout for this operation. Read more
Auto Trait Implementations§
impl Freeze for LineInFileBlockExpectedState
impl RefUnwindSafe for LineInFileBlockExpectedState
impl Send for LineInFileBlockExpectedState
impl Sync for LineInFileBlockExpectedState
impl Unpin for LineInFileBlockExpectedState
impl UnsafeUnpin for LineInFileBlockExpectedState
impl UnwindSafe for LineInFileBlockExpectedState
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