pub struct Env { /* private fields */ }Expand description
A parsed .env / .properties document, backed by a lossless CST.
Implementations§
Trait Implementations§
Source§impl Document for Env
impl Document for Env
Source§fn to_source(&self) -> String
fn to_source(&self) -> String
Byte-identical serialization for an unedited document (the round-trip
invariant). Reflects in-place edits once mutation lands.
Source§fn to_value(&self) -> Value
fn to_value(&self) -> Value
Project to the value model for querying and conversion. Trivia (comments,
layout) is dropped - this is the data-model view, not the source view.
Source§fn apply(&mut self, expr: &Expr) -> Result<Vec<String>, EditError>
fn apply(&mut self, expr: &Expr) -> Result<Vec<String>, EditError>
Apply a mutation expression (assignment /
del) in place,
format-preserving. Query expressions should be evaluated against
Document::to_value instead; use Expr::is_mutation to choose.
Returns any non-fatal warnings (e.g. a multi-document select predicate
that could not be evaluated against some document, so that document was
skipped) for the CLI to surface; an empty vec on a clean edit.Source§fn has_comments(&self) -> bool
fn has_comments(&self) -> bool
Whether the source contains any comments - used to warn on conversion,
which drops them.
Source§fn to_commented(&self) -> Option<Commented>
fn to_commented(&self) -> Option<Commented>
Project to the comment-annotated value model (
Commented) so
conversion can carry comments across formats. Shape and order must match
Document::to_value exactly (same keys, same merge/resolution rules) -
the CLI pairs the two projections by position. None means the format
doesn’t extract comments; conversion then falls back to the plain value
path and warns that comments were dropped.Source§fn set_comment(
&mut self,
path: &[Step],
kind: CommentKind,
text: &str,
) -> Result<Vec<String>, EditError>
fn set_comment( &mut self, path: &[Step], kind: CommentKind, text: &str, ) -> Result<Vec<String>, EditError>
Set the
kind comment on the node at path to text (raw, unwrapped),
format-preserving: only that comment’s bytes change, or one comment line
is inserted. Multi-line head/foot text is wrapped to the document’s
envelope by the implementation. Returns any warnings (a layout that had
to expand to hold the comment, or a kind remapped to one the format
supports). The default rejects - comment editing is added per format.Source§fn delete_comment(
&mut self,
path: &[Step],
kind: CommentKind,
) -> Result<(), EditError>
fn delete_comment( &mut self, path: &[Step], kind: CommentKind, ) -> Result<(), EditError>
Delete the
kind comment on the node at path (a miss is a no-op).
The default rejects - added per format alongside Document::set_comment.Source§fn to_values(&self) -> Vec<Value>
fn to_values(&self) -> Vec<Value>
Project to one value per top-level document. Only YAML has a
multi-document stream (
----separated); every other format is a single
document, so the default is [to_value()]. The CLI evaluates a query
against each in turn and concatenates the results, so .kind over a
multi-doc stream yields one result per document.Source§fn to_commented_all(&self) -> Vec<Commented>
fn to_commented_all(&self) -> Vec<Commented>
One comment-annotated projection per top-level document (the comment
analogue of
Document::to_values). Only YAML has multiple; the default
is the single Document::to_commented, so a comment query maps over
every document of a multi-document stream.Source§fn source_slice(&self, path: &[Step]) -> Vec<String>
fn source_slice(&self, path: &[Step]) -> Vec<String>
The original source text of each node selected by
path, in document
order (aligned 1:1 with crate::eval’s results for the same path). This
is the format-preserving “get”: a structural query returns the exact bytes Read moreSource§fn inner_format(&self) -> Option<&'static str>
fn inner_format(&self) -> Option<&'static str>
The name of the format a query should default its output to, when this
document’s own format isn’t itself emittable. A lens (frontmatter) is not
an output format, so a query over it renders in the underlying block’s
format (
"yaml"/"toml"/"json") instead. None (the default) means
“my own format is the natural output” - the ordinary case.Source§fn set_comment_in_doc(
&mut self,
doc: usize,
path: &[Step],
kind: CommentKind,
text: &str,
) -> Result<Vec<String>, EditError>
fn set_comment_in_doc( &mut self, doc: usize, path: &[Step], kind: CommentKind, text: &str, ) -> Result<Vec<String>, EditError>
Set the
kind comment at path, scoped to a single document of a
multi-document stream (used by bulk comments |= f, where each new
comment derives from that comment’s own text and so must not leak across
documents). Single-document formats have one document, so the default
ignores doc and sets it the ordinary way.Auto Trait Implementations§
impl !RefUnwindSafe for Env
impl !Send for Env
impl !Sync for Env
impl !UnwindSafe for Env
impl Freeze for Env
impl Unpin for Env
impl UnsafeUnpin for Env
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