nvim_rs/exttypes/
window.rs1use futures::io::AsyncWrite;
2use rmpv::Value;
3
4use super::{Buffer, Tabpage};
5use crate::{
6 error::CallError, impl_exttype_traits, rpc::model::IntoVal, Neovim,
7};
8
9pub struct Window<W>
13where
14 W: AsyncWrite + Send + Unpin + 'static,
15{
16 pub(crate) code_data: Value,
17 pub(crate) neovim: Neovim<W>,
18}
19
20impl_exttype_traits!(Window);
21
22impl<W> Window<W>
23where
24 W: AsyncWrite + Send + Unpin + 'static,
25{
26 pub async fn get_buf(&self) -> Result<Buffer<W>, Box<CallError>> {
28 Ok(
29 self
30 .neovim
31 .call("nvim_win_get_buf", call_args![self.code_data.clone()])
32 .await?
33 .map(|val| Buffer::new(val, self.neovim.clone()))?,
34 )
35 }
36 pub async fn get_tabpage(&self) -> Result<Tabpage<W>, Box<CallError>> {
38 Ok(
39 self
40 .neovim
41 .call("nvim_win_get_tabpage", call_args![self.code_data.clone()])
42 .await?
43 .map(|val| Tabpage::new(val, self.neovim.clone()))?,
44 )
45 }
46}