DocumentProvider

Trait DocumentProvider 

Source
pub trait DocumentProvider:
    Environment
    + Send
    + Sync {
    // Required methods
    fn OpenDocument<'life0, 'async_trait>(
        &'life0 self,
        URIComponentsDTO: Value,
        LanguageIdentifier: Option<String>,
        Content: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Url, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn SaveDocument<'life0, 'async_trait>(
        &'life0 self,
        URI: Url,
    ) -> Pin<Box<dyn Future<Output = Result<bool, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn SaveDocumentAs<'life0, 'async_trait>(
        &'life0 self,
        OriginalURI: Url,
        NewTargetURI: Option<Url>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Url>, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn SaveAllDocuments<'life0, 'async_trait>(
        &'life0 self,
        IncludeUntitled: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<bool>, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ApplyDocumentChanges<'life0, 'async_trait>(
        &'life0 self,
        URI: Url,
        NewVersionIdentifier: i64,
        ChangesDTOCollection: Value,
        IsDirtyAfterChange: bool,
        IsUndoing: bool,
        IsRedoing: bool,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

An abstract service contract for an environment component that can manage the lifecycle and content of text documents.

This trait is implemented by MountainEnvironment and is responsible for maintaining the “single source of truth” for all open documents, handling file I/O, and synchronizing state with the Cocoon sidecar.

Required Methods§

Source

fn OpenDocument<'life0, 'async_trait>( &'life0 self, URIComponentsDTO: Value, LanguageIdentifier: Option<String>, Content: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Url, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Opens an existing document from a URI or creates a new untitled document with initial content.

§Parameters
  • URIComponentsDTO: A DTO representing the URI of the document to open.
  • LanguageIdentifier: An optional language ID, typically for new documents.
  • Content: Optional initial content for a new, untitled document.
§Returns

A Result containing the canonical Url of the opened document.

Source

fn SaveDocument<'life0, 'async_trait>( &'life0 self, URI: Url, ) -> Pin<Box<dyn Future<Output = Result<bool, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Saves the document at the given URI to disk.

Source

fn SaveDocumentAs<'life0, 'async_trait>( &'life0 self, OriginalURI: Url, NewTargetURI: Option<Url>, ) -> Pin<Box<dyn Future<Output = Result<Option<Url>, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Saves the document currently identified by OriginalURI to a new location. If NewTargetURI is None, the user should be prompted to select a location.

Source

fn SaveAllDocuments<'life0, 'async_trait>( &'life0 self, IncludeUntitled: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<bool>, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Saves all currently “dirty” (modified) documents.

§Parameters
  • IncludeUntitled: If true, also attempts to save untitled documents, which will typically trigger a “Save As” dialog for each.
Source

fn ApplyDocumentChanges<'life0, 'async_trait>( &'life0 self, URI: Url, NewVersionIdentifier: i64, ChangesDTOCollection: Value, IsDirtyAfterChange: bool, IsUndoing: bool, IsRedoing: bool, ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Applies a collection of content changes to the document at the given URI. This is the primary method for handling edits from the extension host.

§Parameters
  • URI: The URI of the document to modify.
  • NewVersionIdentifier: The new version ID of the document after the change.
  • ChangesDTOCollection: A DTO representing the set of text changes to apply.
  • IsDirtyAfterChange: A flag indicating the document’s dirty state after the change.
  • IsUndoing: A flag indicating if this change is part of an “undo” operation.
  • IsRedoing: A flag indicating if this change is part of a “redo” operation.

Implementors§