Skip to main content

Workspace

Struct Workspace 

Source
pub struct Workspace { /* private fields */ }
Expand description

A collection of open documents/buffers and their state.

Implementations§

Source§

impl Workspace

Source

pub fn new() -> Self

Create an empty workspace.

Source

pub fn len(&self) -> usize

Returns the number of open documents.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no open documents.

Source

pub fn active_document_id(&self) -> Option<DocumentId>

Return the active document id (if any).

Source

pub fn set_active_document( &mut self, id: DocumentId, ) -> Result<(), WorkspaceError>

Set the active document.

Source

pub fn open_document( &mut self, uri: Option<String>, text: &str, viewport_width: usize, ) -> Result<DocumentId, WorkspaceError>

Open a new document in the workspace.

  • uri is optional and host-provided (e.g. file:///...).
  • text is the initial contents.
Source

pub fn close_document(&mut self, id: DocumentId) -> Result<(), WorkspaceError>

Close a document.

Source

pub fn document_id_for_uri(&self, uri: &str) -> Option<DocumentId>

Look up a document by uri.

Source

pub fn document_metadata(&self, id: DocumentId) -> Option<&DocumentMetadata>

Get a document’s metadata.

Source

pub fn set_document_uri( &mut self, id: DocumentId, uri: Option<String>, ) -> Result<(), WorkspaceError>

Update a document’s uri/path.

Source

pub fn document(&self, id: DocumentId) -> Option<&EditorStateManager>

Get an immutable reference to a document state manager.

Source

pub fn document_mut( &mut self, id: DocumentId, ) -> Option<&mut EditorStateManager>

Get a mutable reference to a document state manager.

Source

pub fn active_document(&self) -> Option<&EditorStateManager>

Get the active document (if any).

Source

pub fn active_document_mut(&mut self) -> Option<&mut EditorStateManager>

Get the active document mutably (if any).

Source

pub fn iter(&self) -> impl Iterator<Item = (DocumentId, &EditorStateManager)>

Iterate over open documents in DocumentId order.

Trait Implementations§

Source§

impl Debug for Workspace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Workspace

Source§

fn default() -> Workspace

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.