pub struct DraftTracker { /* private fields */ }Expand description
Tracks in-flight drafts across channels and throttles updates.
Implementations§
Source§impl DraftTracker
impl DraftTracker
pub fn new(update_interval_ms: u64) -> Self
Sourcepub async fn start(
&self,
key: DraftKey,
initial_text: &str,
channel: &Arc<dyn Channel>,
) -> Result<Option<String>>
pub async fn start( &self, key: DraftKey, initial_text: &str, channel: &Arc<dyn Channel>, ) -> Result<Option<String>>
Start a new draft. Calls channel.send_draft() and tracks the returned message ID.
Returns Ok(message_id) if the channel supports drafts and created one,
or Ok(None) if the channel does not support drafts.
Sourcepub async fn update(
&self,
key: &DraftKey,
text: &str,
channel: &Arc<dyn Channel>,
) -> Result<bool>
pub async fn update( &self, key: &DraftKey, text: &str, channel: &Arc<dyn Channel>, ) -> Result<bool>
Update an in-flight draft with new text.
Respects the throttle interval — if called too frequently, the text is
buffered and only the latest version is sent when the interval elapses.
Returns true if an update was actually sent to the channel.
Sourcepub async fn finalize(
&self,
key: &DraftKey,
final_text: &str,
channel: &Arc<dyn Channel>,
) -> Result<()>
pub async fn finalize( &self, key: &DraftKey, final_text: &str, channel: &Arc<dyn Channel>, ) -> Result<()>
Finalize a draft — sends the final text and removes tracking.
Sourcepub async fn cancel(
&self,
key: &DraftKey,
channel: &Arc<dyn Channel>,
) -> Result<()>
pub async fn cancel( &self, key: &DraftKey, channel: &Arc<dyn Channel>, ) -> Result<()>
Cancel a draft — removes tracking and notifies the channel.
Sourcepub async fn has_draft(&self, key: &DraftKey) -> bool
pub async fn has_draft(&self, key: &DraftKey) -> bool
Check if a draft is currently tracked for the given key.
Sourcepub async fn active_count(&self) -> usize
pub async fn active_count(&self) -> usize
Get the number of active drafts.
Auto Trait Implementations§
impl Freeze for DraftTracker
impl !RefUnwindSafe for DraftTracker
impl Send for DraftTracker
impl Sync for DraftTracker
impl Unpin for DraftTracker
impl UnsafeUnpin for DraftTracker
impl !UnwindSafe for DraftTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more