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
use futures::io::AsyncWrite;
use rmpv::Value;
use super::{Buffer, Tabpage};
use crate::{
error::CallError, impl_exttype_traits, rpc::model::IntoVal, Neovim,
};
pub struct Window<W>
where
W: AsyncWrite + Send + Unpin + 'static,
{
pub(crate) code_data: Value,
pub(crate) neovim: Neovim<W>,
}
impl_exttype_traits!(Window);
impl<W> Window<W>
where
W: AsyncWrite + Send + 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()))?,
)
}
}