pub struct WirePosition {
pub line: u32,
pub character: u32,
}Expand description
A protocol-facing LSP position.
Both fields are 0-based. character is measured in UTF-16 code units.
Fields§
§line: u32Zero-based line number.
character: u32Zero-based UTF-16 code-unit offset within the line.
Implementations§
Source§impl WirePosition
impl WirePosition
Sourcepub fn new(line: u32, character: u32) -> Self
pub fn new(line: u32, character: u32) -> Self
Creates a new wire position from explicit line and character values.
Sourcepub fn from_byte_offset(source: &str, byte_offset: usize) -> Self
pub fn from_byte_offset(source: &str, byte_offset: usize) -> Self
Converts a byte offset in source into an LSP wire position.
Sourcepub fn to_byte_offset(&self, source: &str) -> usize
pub fn to_byte_offset(&self, source: &str) -> usize
Converts this LSP wire position back into a byte offset in source.
Trait Implementations§
Source§impl Clone for WirePosition
impl Clone for WirePosition
Source§fn clone(&self) -> WirePosition
fn clone(&self) -> WirePosition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WirePosition
impl Debug for WirePosition
Source§impl Default for WirePosition
impl Default for WirePosition
Source§fn default() -> WirePosition
fn default() -> WirePosition
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for WirePosition
impl<'de> Deserialize<'de> for WirePosition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Position> for WirePosition
Available on crate feature lsp-compat only.
impl From<Position> for WirePosition
Available on crate feature
lsp-compat only.Source§impl From<WirePosition> for Position
Available on crate feature lsp-compat only.
impl From<WirePosition> for Position
Available on crate feature
lsp-compat only.Source§fn from(p: WirePosition) -> Self
fn from(p: WirePosition) -> Self
Converts to this type from the input type.
Source§impl PartialEq for WirePosition
impl PartialEq for WirePosition
Source§impl Serialize for WirePosition
impl Serialize for WirePosition
impl Copy for WirePosition
impl Eq for WirePosition
impl StructuralPartialEq for WirePosition
Auto Trait Implementations§
impl Freeze for WirePosition
impl RefUnwindSafe for WirePosition
impl Send for WirePosition
impl Sync for WirePosition
impl Unpin for WirePosition
impl UnsafeUnpin for WirePosition
impl UnwindSafe for WirePosition
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
Mutably borrows from an owned value. Read more