mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-25 16:34:48 +01:00
feat: faster accessor, fix prelude
This commit is contained in:
parent
4f3e09abd3
commit
4562c2732b
2 changed files with 8 additions and 6 deletions
|
@ -38,21 +38,23 @@ impl Instance {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rt(&self) -> &Runtime { &self.runtime }
|
||||
|
||||
pub fn connect(&self, addr: &str) -> Result<(), Error> {
|
||||
*self.client.lock().expect("client mutex poisoned") = Some(self.runtime.block_on(Client::new(addr))?);
|
||||
*self.client.lock().expect("client mutex poisoned") = Some(self.rt().block_on(Client::new(addr))?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn join(&self, session: &str) -> Result<Arc<CursorController>, Error> {
|
||||
self.if_client(|c| self.runtime.block_on(c.join(session)))?
|
||||
self.if_client(|c| self.rt().block_on(c.join(session)))?
|
||||
}
|
||||
|
||||
pub fn create(&self, path: &str, content: Option<&str>) -> Result<(), Error> {
|
||||
self.if_client(|c| self.runtime.block_on(c.create(path, content)))?
|
||||
self.if_client(|c| self.rt().block_on(c.create(path, content)))?
|
||||
}
|
||||
|
||||
pub fn attach(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
||||
self.if_client(|c| self.runtime.block_on(c.attach(path)))?
|
||||
self.if_client(|c| self.rt().block_on(c.attach(path)))?
|
||||
}
|
||||
|
||||
pub fn get_cursor(&self) -> Result<Arc<CursorController>, Error> {
|
||||
|
|
|
@ -7,5 +7,5 @@ pub use crate::buffer::controller::BufferController as CodempBufferController;
|
|||
pub use crate::buffer::TextChange as CodempTextChange;
|
||||
pub use crate::proto::CursorPosition as CodempCursorPosition;
|
||||
|
||||
#[cfg(feature = "static")]
|
||||
pub use crate::instance::INSTANCE as CODEMP_INSTANCE;
|
||||
#[cfg(feature = "global")]
|
||||
pub use crate::instance::global::INSTANCE as CODEMP_INSTANCE;
|
||||
|
|
Loading…
Reference in a new issue