1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use super::{Buffer, Tabpage};
use crate::{
error::CallError, rpc::model::IntoVal, runtime::AsyncWrite, Neovim,
};
use rmpv::Value;
#[derive(Clone)]
pub struct Window<W>
where
W: AsyncWrite + Send + Unpin + 'static,
{
pub(crate) code_data: Value,
pub(crate) neovim: Neovim<W>,
}
impl<W> Window<W>
where
W: AsyncWrite + Send + Sync + Unpin + 'static,
{
pub async fn get_buf(&self) -> Result<Buffer<W>, Box<CallError>> {
Ok(
self
.neovim
.call("nvim_win_get_buf", call_args![self.code_data.clone()])
.await?
.map(|val| Buffer::new(val, self.neovim.clone()))?,
)
}
pub async fn get_tabpage(&self) -> Result<Tabpage<W>, Box<CallError>> {
Ok(
self
.neovim
.call("nvim_win_get_tabpage", call_args![self.code_data.clone()])
.await?
.map(|val| Tabpage::new(val, self.neovim.clone()))?,
)
}
}
impl<W> IntoVal<Value> for &Window<W>
where
W: AsyncWrite + Send + Sync + Unpin + 'static,
{
fn into_val(self) -> Value {
self.code_data.clone()
}
}