pub struct Directive {
pub name: String,
pub name_span: Span,
pub args: Vec<Argument>,
pub block: Option<Block>,
pub span: Span,
pub trailing_comment: Option<Comment>,
pub leading_whitespace: String,
pub space_before_terminator: String,
pub trailing_whitespace: String,
}Expand description
A directive — either a simple directive (listen 80;) or a block directive
(server { … }).
The span covers the entire directive from the first
character of the name to the terminating ; or closing }.
Fields§
§name: StringDirective name (e.g. "server", "listen", "more_set_headers").
name_span: SpanSpan of the directive name token.
args: Vec<Argument>Arguments following the directive name.
block: Option<Block>Block body, present for block directives like server { … }.
span: SpanSpan covering the entire directive (name through terminator).
trailing_comment: Option<Comment>Optional comment at the end of the directive line.
leading_whitespace: StringLeading whitespace before the directive name (for indentation checking)
space_before_terminator: StringWhitespace before the terminator (; or {)
trailing_whitespace: StringTrailing whitespace after the terminator (; or {) to end of line
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Directive
impl<'de> Deserialize<'de> for Directive
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Directive, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Directive, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl DirectiveExt for Box<Directive>
impl DirectiveExt for Box<Directive>
Source§fn first_arg_is(&self, value: &str) -> bool
fn first_arg_is(&self, value: &str) -> bool
Check if the first argument equals the given value.
Source§fn full_start_offset(&self) -> usize
fn full_start_offset(&self) -> usize
Get the byte offset including leading whitespace.
Source§fn replace_with(&self, new_text: &str) -> Fix
fn replace_with(&self, new_text: &str) -> Fix
Create a
Fix that replaces this directive with new text, preserving indentation.Source§fn delete_line(&self) -> Fix
fn delete_line(&self) -> Fix
Create a
Fix that deletes this directive’s line.Source§fn insert_after(&self, new_text: &str) -> Fix
fn insert_after(&self, new_text: &str) -> Fix
Create a
Fix that inserts a new line after this directive, matching indentation.Source§fn insert_after_many(&self, lines: &[&str]) -> Fix
fn insert_after_many(&self, lines: &[&str]) -> Fix
Create a
Fix that inserts multiple new lines after this directive.Source§impl DirectiveExt for Directive
impl DirectiveExt for Directive
Source§fn first_arg_is(&self, value: &str) -> bool
fn first_arg_is(&self, value: &str) -> bool
Check if the first argument equals the given value.
Source§fn full_start_offset(&self) -> usize
fn full_start_offset(&self) -> usize
Get the byte offset including leading whitespace.
Source§fn replace_with(&self, new_text: &str) -> Fix
fn replace_with(&self, new_text: &str) -> Fix
Create a
Fix that replaces this directive with new text, preserving indentation.Source§fn delete_line(&self) -> Fix
fn delete_line(&self) -> Fix
Create a
Fix that deletes this directive’s line.Source§fn insert_after(&self, new_text: &str) -> Fix
fn insert_after(&self, new_text: &str) -> Fix
Create a
Fix that inserts a new line after this directive, matching indentation.Source§fn insert_after_many(&self, lines: &[&str]) -> Fix
fn insert_after_many(&self, lines: &[&str]) -> Fix
Create a
Fix that inserts multiple new lines after this directive.Source§impl Serialize for Directive
impl Serialize for Directive
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Directive
impl RefUnwindSafe for Directive
impl Send for Directive
impl Sync for Directive
impl Unpin for Directive
impl UnsafeUnpin for Directive
impl UnwindSafe for Directive
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