pub struct WasmDocument { /* private fields */ }Expand description
A YAML document with byte-faithful source preservation and path-targeted edits.
Implementations§
Source§impl WasmDocument
impl WasmDocument
Sourcepub fn new(yaml: &str) -> Result<WasmDocument, JsError>
pub fn new(yaml: &str) -> Result<WasmDocument, JsError>
Parse a YAML string into a lossless Document.
Sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Re-emit the document as a string. Byte-identical to original if no edits.
Bound on the JS side as toString() (the conventional camelCase
name) so callers can write doc.toString() and override the
default Object.prototype.toString rather than coexist with it.
Sourcepub fn replace_span(
&mut self,
start: usize,
end: usize,
replacement: &str,
) -> Result<(), JsError>
pub fn replace_span( &mut self, start: usize, end: usize, replacement: &str, ) -> Result<(), JsError>
Replace the bytes at start..end with replacement.
Bound on the JS side as replaceSpan(start, end, replacement)
per JS naming conventions.
Sourcepub fn get(&self, path: &str) -> Result<JsValue, JsError>
pub fn get(&self, path: &str) -> Result<JsValue, JsError>
Get the parsed value at a dotted path.
Sourcepub fn get_source(&self, path: &str) -> JsValue
pub fn get_source(&self, path: &str) -> JsValue
Get the raw source fragment at a dotted path.
Bound on the JS side as getSource(path) per JS naming
conventions.
Sourcepub fn span_at(&self, path: &str) -> Result<JsValue, JsError>
pub fn span_at(&self, path: &str) -> Result<JsValue, JsError>
Get the byte range { start, end } for the value at a dotted path.
Bound on the JS side as spanAt(path) per JS naming
conventions.
Sourcepub fn set_value(&mut self, path: &str, value: JsValue) -> Result<(), JsError>
pub fn set_value(&mut self, path: &str, value: JsValue) -> Result<(), JsError>
Set a value at a dotted path using a JS object.
Bound on the JS side as setValue(path, value) per JS naming
conventions.
Sourcepub fn set(&mut self, path: &str, fragment: &str) -> Result<(), JsError>
pub fn set(&mut self, path: &str, fragment: &str) -> Result<(), JsError>
Set a value at a dotted path using a YAML fragment string.
Sourcepub fn comments_at(&self, path: &str) -> Result<JsValue, JsError>
pub fn comments_at(&self, path: &str) -> Result<JsValue, JsError>
Read the YAML comments associated with the node at path.
Returns { before: string[], inline: string | null } so the
caller can surface human-authored doc-comments alongside
values — the demo that motivates the entire CST architecture.
Bound on the JS side as commentsAt(path) per JS naming
conventions.
Source§impl WasmDocument
impl WasmDocument
Sourcepub fn as_document(&self) -> &Document
pub fn as_document(&self) -> &Document
Native (rlib) accessor for the inner Document. Lets
cargo test exercise the underlying state transitions
without going through a JS shell.
Trait Implementations§
Source§impl From<WasmDocument> for JsValue
impl From<WasmDocument> for JsValue
Source§fn from(value: WasmDocument) -> Self
fn from(value: WasmDocument) -> Self
Source§impl FromWasmAbi for WasmDocument
impl FromWasmAbi for WasmDocument
Source§impl IntoWasmAbi for WasmDocument
impl IntoWasmAbi for WasmDocument
Source§impl LongRefFromWasmAbi for WasmDocument
impl LongRefFromWasmAbi for WasmDocument
Source§type Abi = WasmPtr<WasmRefCell<WasmDocument>>
type Abi = WasmPtr<WasmRefCell<WasmDocument>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmDocument>
type Anchor = RcRef<WasmDocument>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmDocument
impl OptionFromWasmAbi for WasmDocument
Source§impl OptionIntoWasmAbi for WasmDocument
impl OptionIntoWasmAbi for WasmDocument
Source§impl RefFromWasmAbi for WasmDocument
impl RefFromWasmAbi for WasmDocument
Source§type Abi = WasmPtr<WasmRefCell<WasmDocument>>
type Abi = WasmPtr<WasmRefCell<WasmDocument>>
Self are recovered from.Source§type Anchor = RcRef<WasmDocument>
type Anchor = RcRef<WasmDocument>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmDocument
impl RefMutFromWasmAbi for WasmDocument
Source§type Abi = WasmPtr<WasmRefCell<WasmDocument>>
type Abi = WasmPtr<WasmRefCell<WasmDocument>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmDocument>
type Anchor = RcRefMut<WasmDocument>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for WasmDocument
impl SupportsInstanceProperty for WasmDocument
impl SupportsStaticProperty for WasmDocument
Source§impl TryFromJsValue for WasmDocument
impl TryFromJsValue for WasmDocument
Source§impl VectorFromWasmAbi for WasmDocument
impl VectorFromWasmAbi for WasmDocument
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmDocument]>
Source§impl VectorIntoWasmAbi for WasmDocument
impl VectorIntoWasmAbi for WasmDocument
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmDocument]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmDocument
impl WasmDescribeVector for WasmDocument
Auto Trait Implementations§
impl !Freeze for WasmDocument
impl !RefUnwindSafe for WasmDocument
impl !Sync for WasmDocument
impl Send for WasmDocument
impl Unpin for WasmDocument
impl UnsafeUnpin for WasmDocument
impl UnwindSafe for WasmDocument
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
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.