nvim_api/types/
extmark_position.rs

1use nvim_types::{Array, Integer, Object};
2use serde::Deserialize;
3
4#[non_exhaustive]
5#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Deserialize)]
6pub enum ExtmarkPosition {
7    /// Defines the extmark's position in the buffer by a 0-indexed `(row,
8    /// col)` tuple.
9    ByTuple((usize, usize)),
10
11    /// Defines the extmark's position in the buffer by its id.
12    ById(u32),
13}
14
15impl From<ExtmarkPosition> for Object {
16    fn from(pos: ExtmarkPosition) -> Self {
17        use ExtmarkPosition::*;
18
19        match pos {
20            ByTuple((row, col)) => {
21                Array::from_iter([row as Integer, col as Integer]).into()
22            },
23            ById(extmark_id) => extmark_id.into(),
24        }
25    }
26}