From 781a130c62df3c2e4436081591d4981e1d3f0d9f Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 10 Aug 2024 16:13:16 +0200 Subject: [PATCH] chore: moved tools into ext --- src/buffer/controller.rs | 2 +- src/buffer/mod.rs | 3 --- src/{buffer/tools.rs => ext.rs} | 8 ++++++++ src/lib.rs | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) rename src/{buffer/tools.rs => ext.rs} (90%) diff --git a/src/buffer/controller.rs b/src/buffer/controller.rs index 9fd883f..057bda6 100644 --- a/src/buffer/controller.rs +++ b/src/buffer/controller.rs @@ -12,7 +12,7 @@ use crate::api::Controller; use crate::api::TextChange; -use super::tools::InternallyMutable; +use crate::ext::InternallyMutable; /// the buffer controller implementation /// diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs index dfaff9f..1610400 100644 --- a/src/buffer/mod.rs +++ b/src/buffer/mod.rs @@ -9,9 +9,6 @@ /// buffer controller implementation pub mod controller; -/// assorted helpers to handle buffer controllers -pub mod tools; - pub(crate) mod worker; pub use controller::BufferController as Controller; diff --git a/src/buffer/tools.rs b/src/ext.rs similarity index 90% rename from src/buffer/tools.rs rename to src/ext.rs index 0e40359..2bfc362 100644 --- a/src/buffer/tools.rs +++ b/src/ext.rs @@ -81,3 +81,11 @@ impl InternallyMutable { self.getter.borrow().clone() } } + +pub(crate) struct CallbackHandleWatch(pub(crate) tokio::sync::watch::Sender>); + +impl crate::api::controller::CallbackHandle for CallbackHandleWatch { + fn unregister(self) { + self.0.send_replace(None); + } +} diff --git a/src/lib.rs b/src/lib.rs index c2f502f..99390df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,6 +140,9 @@ pub mod prelude; /// language-specific ffi "glue" pub mod ffi; +/// common utils used in this library and re-exposed +pub mod ext; + /// underlying OperationalTransform library used, re-exported pub use woot;