diff --git a/src/instance.rs b/src/instance.rs index 28439fc..b7772be 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -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, 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, 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, Error> { diff --git a/src/prelude.rs b/src/prelude.rs index dda8c2c..ca52cd6 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -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;