pub struct Document { /* private fields */ }Expand description
A parsed document that owns its unchanged source text.
Implementations§
Source§impl Document
impl Document
Sourcepub fn parse(source: impl Into<String>, limits: &Limits) -> Result<Self, Error>
pub fn parse(source: impl Into<String>, limits: &Limits) -> Result<Self, Error>
Parses a complete document.
§Errors
Returns the first syntax or limit violation with its byte offset.
pub fn source(&self) -> &str
pub const fn root(&self) -> &Value
Sourcepub fn canonical(&self, value: &Value) -> String
pub fn canonical(&self, value: &Value) -> String
Canonical minified JSON for a value of this document: no comments or
whitespace, members in source order, numbers spelled exactly as in the
source, and strings escaped minimally (", \\ and control
characters only). Equal values from equal source text always give
equal output.
§Panics
Panics if the value is not part of this document.
Sourcepub fn replace(
&self,
span: Span,
text: &str,
limits: &Limits,
) -> Result<Self, Error>
pub fn replace( &self, span: Span, text: &str, limits: &Limits, ) -> Result<Self, Error>
Replaces one span with new text and parses the result. Every byte outside the span is preserved.
§Errors
Returns ErrorCode::InvalidEdit for a span outside the document or
not on character boundaries, or any error of the edited document.
Trait Implementations§
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Forget for Document
impl Freeze for Document
impl Move for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
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