Skip to main content

DocApi

Struct DocApi 

Source
pub struct DocApi<'a, I: Invoker> { /* private fields */ }

Implementations§

Source§

impl<'a, I: Invoker> DocApi<'a, I>

Source

pub fn new(invoker: &'a I) -> Self

Source

pub fn authorities(&self) -> DocApiAuthorities<'a, I>

Source

pub fn blocks(&self) -> DocApiBlocks<'a, I>

Source

pub fn bookmarks(&self) -> DocApiBookmarks<'a, I>

Source

pub fn capabilities(&self) -> DocApiCapabilities<'a, I>

Source

pub fn captions(&self) -> DocApiCaptions<'a, I>

Source

pub fn citations(&self) -> DocApiCitations<'a, I>

Source

pub fn clipboard(&self) -> DocApiClipboard<'a, I>

Source

pub fn comments(&self) -> DocApiComments<'a, I>

Source

pub fn content_controls(&self) -> DocApiContentControls<'a, I>

Source

pub fn create(&self) -> DocApiCreate<'a, I>

Source

pub fn cross_refs(&self) -> DocApiCrossRefs<'a, I>

Source

pub fn custom_xml(&self) -> DocApiCustomXml<'a, I>

Source

pub fn diff(&self) -> DocApiDiff<'a, I>

Source

pub fn export(&self) -> DocApiExport<'a, I>

Source

pub fn fields(&self) -> DocApiFields<'a, I>

Source

pub fn footnotes(&self) -> DocApiFootnotes<'a, I>

Source

pub fn format(&self) -> DocApiFormat<'a, I>

Source

pub fn header_footers(&self) -> DocApiHeaderFooters<'a, I>

Source

pub fn history(&self) -> DocApiHistory<'a, I>

Source

pub fn images(&self) -> DocApiImages<'a, I>

Source

pub fn index(&self) -> DocApiIndex<'a, I>

Source

pub fn lists(&self) -> DocApiLists<'a, I>

Source

pub fn metadata(&self) -> DocApiMetadata<'a, I>

Source

pub fn mutations(&self) -> DocApiMutations<'a, I>

Source

pub fn permission_ranges(&self) -> DocApiPermissionRanges<'a, I>

Source

pub fn plan(&self) -> DocApiPlan<'a, I>

Source

pub fn preset(&self) -> DocApiPreset<'a, I>

Source

pub fn protection(&self) -> DocApiProtection<'a, I>

Source

pub fn query(&self) -> DocApiQuery<'a, I>

Source

pub fn ranges(&self) -> DocApiRanges<'a, I>

Source

pub fn sections(&self) -> DocApiSections<'a, I>

Source

pub fn selection(&self) -> DocApiSelection<'a, I>

Source

pub fn styles(&self) -> DocApiStyles<'a, I>

Source

pub fn tables(&self) -> DocApiTables<'a, I>

Source

pub fn templates(&self) -> DocApiTemplates<'a, I>

Source

pub fn toc(&self) -> DocApiToc<'a, I>

Source

pub fn track_changes(&self) -> DocApiTrackChanges<'a, I>

Source

pub fn watermarks(&self) -> DocApiWatermarks<'a, I>

Source

pub fn clear_content<'call>( &'call self, params: &'call DocClearContentBoundParams, ) -> impl Future<Output = Result<DocClearContentResult>> + Send + 'call

Clear all document body content, leaving a single empty paragraph.

Source

pub async fn clear_content_with_options( &self, params: &DocClearContentBoundParams, options: InvokeOptions, ) -> Result<DocClearContentResult>

Clear all document body content, leaving a single empty paragraph.

Source

pub fn close<'call>( &'call self, params: &'call DocCloseBoundParams, ) -> impl Future<Output = Result<DocCloseResult>> + Send + 'call

Close the active editing session and clean up resources.

Source

pub async fn close_with_options( &self, params: &DocCloseBoundParams, options: InvokeOptions, ) -> Result<DocCloseResult>

Close the active editing session and clean up resources.

Source

pub fn delete<'call>( &'call self, params: &'call DocDeleteBoundParams, ) -> impl Future<Output = Result<DocDeleteResult>> + Send + 'call

Delete content at a contiguous document selection. Accepts a SelectionTarget or mutation-ready ref. Supports cross-block deletion and optional block-edge expansion via behavior mode.

Source

pub async fn delete_with_options( &self, params: &DocDeleteBoundParams, options: InvokeOptions, ) -> Result<DocDeleteResult>

Delete content at a contiguous document selection. Accepts a SelectionTarget or mutation-ready ref. Supports cross-block deletion and optional block-edge expansion via behavior mode.

Source

pub fn execute_code<'call>( &'call self, params: &'call DocExecuteCodeBoundParams, ) -> impl Future<Output = Result<DocExecuteCodeResult>> + Send + 'call

Run model-authored JavaScript IN-HOST against the live, SYNCHRONOUS Document API for the open session. Two globals are injected: doc (the synchronous Document API; do NOT await doc.* calls) and console. return a short summary; logs and the return value come back structured as { ok, result, logs, error }. Use for complex/multi-step workflows (loops, per-item branching, extract-then-generate) in ONE call instead of chaining many narrow tools. Large code can be passed on stdin.

Source

pub async fn execute_code_with_options( &self, params: &DocExecuteCodeBoundParams, options: InvokeOptions, ) -> Result<DocExecuteCodeResult>

Run model-authored JavaScript IN-HOST against the live, SYNCHRONOUS Document API for the open session. Two globals are injected: doc (the synchronous Document API; do NOT await doc.* calls) and console. return a short summary; logs and the return value come back structured as { ok, result, logs, error }. Use for complex/multi-step workflows (loops, per-item branching, extract-then-generate) in ONE call instead of chaining many narrow tools. Large code can be passed on stdin.

Source

pub fn extract<'call>( &'call self, params: &'call DocExtractBoundParams, ) -> impl Future<Output = Result<DocExtractResult>> + Send + 'call

Extract all document content with stable IDs for RAG pipelines. Returns blocks with full text, comments, and tracked changes: each with an ID compatible with scrollToElement().

Source

pub async fn extract_with_options( &self, params: &DocExtractBoundParams, options: InvokeOptions, ) -> Result<DocExtractResult>

Extract all document content with stable IDs for RAG pipelines. Returns blocks with full text, comments, and tracked changes: each with an ID compatible with scrollToElement().

Source

pub fn find<'call>( &'call self, params: &'call DocFindBoundParams, ) -> impl Future<Output = Result<DocFindResult>> + Send + 'call

Search the document for text or node matches using SDM/1 selectors. Returns discovery-grade results: for mutation targeting, use query.match instead.

Source

pub async fn find_with_options( &self, params: &DocFindBoundParams, options: InvokeOptions, ) -> Result<DocFindResult>

Search the document for text or node matches using SDM/1 selectors. Returns discovery-grade results: for mutation targeting, use query.match instead.

Source

pub fn format_range<'call>( &'call self, params: &'call DocFormatRangeBoundParams, ) -> impl Future<Output = Result<DocFormatRangeResult>> + Send + 'call

Legacy root-level alias for inline range formatting. Routes to format.apply for compatibility with older callers.

Source

pub async fn format_range_with_options( &self, params: &DocFormatRangeBoundParams, options: InvokeOptions, ) -> Result<DocFormatRangeResult>

Legacy root-level alias for inline range formatting. Routes to format.apply for compatibility with older callers.

Source

pub fn get<'call>( &'call self, params: &'call DocGetBoundParams, ) -> impl Future<Output = Result<DocGetResult>> + Send + 'call

Read the full document as an SDDocument structure.

Source

pub async fn get_with_options( &self, params: &DocGetBoundParams, options: InvokeOptions, ) -> Result<DocGetResult>

Read the full document as an SDDocument structure.

Source

pub fn get_html<'call>( &'call self, params: &'call DocGetHtmlBoundParams, ) -> impl Future<Output = Result<DocGetHtmlResult>> + Send + 'call

Extract the document content as an HTML string.

Source

pub async fn get_html_with_options( &self, params: &DocGetHtmlBoundParams, options: InvokeOptions, ) -> Result<DocGetHtmlResult>

Extract the document content as an HTML string.

Source

pub fn get_markdown<'call>( &'call self, params: &'call DocGetMarkdownBoundParams, ) -> impl Future<Output = Result<DocGetMarkdownResult>> + Send + 'call

Extract the document content as a Markdown string.

Source

pub async fn get_markdown_with_options( &self, params: &DocGetMarkdownBoundParams, options: InvokeOptions, ) -> Result<DocGetMarkdownResult>

Extract the document content as a Markdown string.

Source

pub fn get_node<'call>( &'call self, params: &'call DocGetNodeBoundParams, ) -> impl Future<Output = Result<DocGetNodeResult>> + Send + 'call

Retrieve a single node by target position.

Source

pub async fn get_node_with_options( &self, params: &DocGetNodeBoundParams, options: InvokeOptions, ) -> Result<DocGetNodeResult>

Retrieve a single node by target position.

Source

pub fn get_node_by_id<'call>( &'call self, params: &'call DocGetNodeByIdBoundParams, ) -> impl Future<Output = Result<DocGetNodeByIdResult>> + Send + 'call

Resolve a block ID across the body, linked headers/footers, and supported textboxes, optionally restricted by story. Paragraphs at every table-cell depth and top-level body/header/footer tables are supported; notes, comments, glossary, and nested table containers are excluded.

Source

pub async fn get_node_by_id_with_options( &self, params: &DocGetNodeByIdBoundParams, options: InvokeOptions, ) -> Result<DocGetNodeByIdResult>

Resolve a block ID across the body, linked headers/footers, and supported textboxes, optionally restricted by story. Paragraphs at every table-cell depth and top-level body/header/footer tables are supported; notes, comments, glossary, and nested table containers are excluded.

Source

pub fn get_text<'call>( &'call self, params: &'call DocGetTextBoundParams, ) -> impl Future<Output = Result<DocGetTextResult>> + Send + 'call

Extract the plain-text content of the document.

Source

pub async fn get_text_with_options( &self, params: &DocGetTextBoundParams, options: InvokeOptions, ) -> Result<DocGetTextResult>

Extract the plain-text content of the document.

Source

pub fn html_to_fragment<'call>( &'call self, params: &'call DocHtmlToFragmentBoundParams, ) -> impl Future<Output = Result<DocHtmlToFragmentResult>> + Send + 'call

Convert an HTML string into an SDM/1 structural fragment.

Source

pub async fn html_to_fragment_with_options( &self, params: &DocHtmlToFragmentBoundParams, options: InvokeOptions, ) -> Result<DocHtmlToFragmentResult>

Convert an HTML string into an SDM/1 structural fragment.

Source

pub fn info<'call>( &'call self, params: &'call DocInfoBoundParams, ) -> impl Future<Output = Result<DocInfoResult>> + Send + 'call

Return document summary info including word, character, paragraph, heading, table, image, comment, tracked-change, SDT-field, list, and page counts, plus outline and capabilities.

Source

pub async fn info_with_options( &self, params: &DocInfoBoundParams, options: InvokeOptions, ) -> Result<DocInfoResult>

Return document summary info including word, character, paragraph, heading, table, image, comment, tracked-change, SDT-field, list, and page counts, plus outline and capabilities.

Source

pub fn insert<'call>( &'call self, params: &'call DocInsertBoundParams, ) -> impl Future<Output = Result<DocInsertResult>> + Send + 'call

Insert content into the document. Text, rich, structural, and native OOXML input shapes: text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target/ref is omitted, content appends at the end of the document. Text mode supports text (default), markdown, and html. Native type:ooxml accepts namespaces and dependency manifests, or capture accepts a portable selection.extractOoxml result. Native copies remap package and review identities and require direct mode. Rich markdown/html and structural modes use placement (before/after/insideStart/insideEnd) to position relative to a block target.

Source

pub async fn insert_with_options( &self, params: &DocInsertBoundParams, options: InvokeOptions, ) -> Result<DocInsertResult>

Insert content into the document. Text, rich, structural, and native OOXML input shapes: text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target/ref is omitted, content appends at the end of the document. Text mode supports text (default), markdown, and html. Native type:ooxml accepts namespaces and dependency manifests, or capture accepts a portable selection.extractOoxml result. Native copies remap package and review identities and require direct mode. Rich markdown/html and structural modes use placement (before/after/insideStart/insideEnd) to position relative to a block target.

Source

pub fn insert_line_break<'call>( &'call self, params: &'call DocInsertLineBreakBoundParams, ) -> impl Future<Output = Result<DocInsertLineBreakResult>> + Send + 'call

Insert a real Word line-break node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.

Source

pub async fn insert_line_break_with_options( &self, params: &DocInsertLineBreakBoundParams, options: InvokeOptions, ) -> Result<DocInsertLineBreakResult>

Insert a real Word line-break node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.

Source

pub fn insert_tab<'call>( &'call self, params: &'call DocInsertTabBoundParams, ) -> impl Future<Output = Result<DocInsertTabResult>> + Send + 'call

Insert a real Word tab node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.

Source

pub async fn insert_tab_with_options( &self, params: &DocInsertTabBoundParams, options: InvokeOptions, ) -> Result<DocInsertTabResult>

Insert a real Word tab node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.

Source

pub fn markdown_to_fragment<'call>( &'call self, params: &'call DocMarkdownToFragmentBoundParams, ) -> impl Future<Output = Result<DocMarkdownToFragmentResult>> + Send + 'call

Convert a Markdown string into an SDM/1 structural fragment.

Source

pub async fn markdown_to_fragment_with_options( &self, params: &DocMarkdownToFragmentBoundParams, options: InvokeOptions, ) -> Result<DocMarkdownToFragmentResult>

Convert a Markdown string into an SDM/1 structural fragment.

Source

pub fn project_html<'call>( &'call self, params: &'call DocProjectHtmlBoundParams, ) -> impl Future<Output = Result<DocProjectHtmlResult>> + Send + 'call

Project document content as HTML with review, scope, diagnostics, and provenance metadata.

Source

pub async fn project_html_with_options( &self, params: &DocProjectHtmlBoundParams, options: InvokeOptions, ) -> Result<DocProjectHtmlResult>

Project document content as HTML with review, scope, diagnostics, and provenance metadata.

Source

pub fn project_markdown<'call>( &'call self, params: &'call DocProjectMarkdownBoundParams, ) -> impl Future<Output = Result<DocProjectMarkdownResult>> + Send + 'call

Project document content as Markdown with review, scope, diagnostics, and provenance metadata.

Source

pub async fn project_markdown_with_options( &self, params: &DocProjectMarkdownBoundParams, options: InvokeOptions, ) -> Result<DocProjectMarkdownResult>

Project document content as Markdown with review, scope, diagnostics, and provenance metadata.

Source

pub fn replace<'call>( &'call self, params: &'call DocReplaceBoundParams, ) -> impl Future<Output = Result<DocReplaceResult>> + Send + 'call

Optional replaceMode:contents retains one paragraph, heading, or listItem container while applying text, HTML, Markdown, SDFragment, or native OOXML inlines. A retained snapshotId source restores exact same-session original markup with an expectedSnapshotId local precondition. These writes require direct mode; existing selection and structural behavior is unchanged. Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. For explicit single-paragraph text selections, expectedText rejects mismatches with PRECONDITION_FAILED before mutation. Tracked text replacements accept replacementGranularity: word (default), phrase (join neighboring edits separated only by spaces), or range (replace the complete selection). This requires an explicit single-paragraph text selection. Rich string path accepts HTML or Markdown plus a BlockNodeAddress, SelectionTarget, or ref. Structural path accepts the same locator forms plus SDFragment content. A single-paragraph rich replacement may overlap pending insertions: tracked mode drops the covered part of your own insertion, nests a deletion inside another author’s insertion, and adds the content as a new insertion; direct mode removes the covered part and leaves the rest pending. A tracked rich replacement spanning paragraphs that crosses a pending insertion, or a range that mixes pending insertions with comment, bookmark, field, or content-control markup, rejects without changes; capabilities.check reports the same result. An explicit {kind:‘story’, storyType:‘body’} target replaces the complete main body in direct mode while preserving the destination DOCX package.

Source

pub async fn replace_with_options( &self, params: &DocReplaceBoundParams, options: InvokeOptions, ) -> Result<DocReplaceResult>

Optional replaceMode:contents retains one paragraph, heading, or listItem container while applying text, HTML, Markdown, SDFragment, or native OOXML inlines. A retained snapshotId source restores exact same-session original markup with an expectedSnapshotId local precondition. These writes require direct mode; existing selection and structural behavior is unchanged. Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. For explicit single-paragraph text selections, expectedText rejects mismatches with PRECONDITION_FAILED before mutation. Tracked text replacements accept replacementGranularity: word (default), phrase (join neighboring edits separated only by spaces), or range (replace the complete selection). This requires an explicit single-paragraph text selection. Rich string path accepts HTML or Markdown plus a BlockNodeAddress, SelectionTarget, or ref. Structural path accepts the same locator forms plus SDFragment content. A single-paragraph rich replacement may overlap pending insertions: tracked mode drops the covered part of your own insertion, nests a deletion inside another author’s insertion, and adds the content as a new insertion; direct mode removes the covered part and leaves the rest pending. A tracked rich replacement spanning paragraphs that crosses a pending insertion, or a range that mixes pending insertions with comment, bookmark, field, or content-control markup, rejects without changes; capabilities.check reports the same result. An explicit {kind:‘story’, storyType:‘body’} target replaces the complete main body in direct mode while preserving the destination DOCX package.

Source

pub fn save<'call>( &'call self, params: &'call DocSaveBoundParams, ) -> impl Future<Output = Result<DocSaveResult>> + Send + 'call

Save the current session to the original file or a new path. Supports explicit review-preserving, final, and original export modes.

Source

pub async fn save_with_options( &self, params: &DocSaveBoundParams, options: InvokeOptions, ) -> Result<DocSaveResult>

Save the current session to the original file or a new path. Supports explicit review-preserving, final, and original export modes.

Auto Trait Implementations§

§

impl<'a, I> Freeze for DocApi<'a, I>
where &'a I: Freeze,

§

impl<'a, I> RefUnwindSafe for DocApi<'a, I>

§

impl<'a, I> Send for DocApi<'a, I>
where &'a I: Send,

§

impl<'a, I> Sync for DocApi<'a, I>
where &'a I: Sync,

§

impl<'a, I> Unpin for DocApi<'a, I>
where &'a I: Unpin,

§

impl<'a, I> UnsafeUnpin for DocApi<'a, I>

§

impl<'a, I> UnwindSafe for DocApi<'a, I>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.