pub struct DocumentsView { /* private fields */ }Expand description
The read-only view of the connection’s documents that
Context::documents hands to user code
(ADR 0018).
It carries the retained Document lookup and the position-conversion
behavior, and deliberately nothing else: there is no open, close, or
change operation to call. Documents change only through the protocol
engine’s built-in didOpen, didChange, and didClose handling, and a
registered post-mutation hook observes the result.
Cheap to clone — every copy reads the documents the connection owns.
Implementations§
Source§impl DocumentsView
impl DocumentsView
Sourcepub fn get(&self, uri: &Uri) -> Option<Document>
pub fn get(&self, uri: &Uri) -> Option<Document>
Read a snapshot of a document by URI, or None if it is not open.
The lookup resolves through the connection’s normalized URI identity
(scheme and host case, percent-encoding, and Windows drive-letter case
are equivalent spellings of one document), while the returned
Document keeps the original URI the client opened it with.
Sourcepub fn position_to_offset(&self, uri: &Uri, position: Position) -> Option<usize>
pub fn position_to_offset(&self, uri: &Uri, position: Position) -> Option<usize>
Convert a position in uri to a byte offset using the connection’s
negotiated encoding. None if the document is not open or the position
is out of range.
Sourcepub fn offset_to_position(&self, uri: &Uri, offset: usize) -> Option<Position>
pub fn offset_to_position(&self, uri: &Uri, offset: usize) -> Option<Position>
Convert a byte offset in uri to a position using the connection’s
negotiated encoding. None if the document is not open or the offset is
out of range.
Sourcepub fn position_encoding(&self) -> PositionEncoding
pub fn position_encoding(&self) -> PositionEncoding
The encoding Position.character is measured in for this connection,
negotiated during initialization (ADR 0016).
Trait Implementations§
Source§impl Clone for DocumentsView
impl Clone for DocumentsView
Source§fn clone(&self) -> DocumentsView
fn clone(&self) -> DocumentsView
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more