pub struct SubscriptionManager { /* private fields */ }Expand description
Manages WebSocket subscriptions for real-time change notifications.
§Examples
use kalam_client::KalamLinkClient;
let client = KalamLinkClient::builder().base_url("http://localhost:3000").build()?;
let mut subscription = client.live_events("SELECT * FROM messages").await?;
while let Some(event) = subscription.next().await {
match event {
Ok(change) => println!("Change detected: {:?}", change),
Err(e) => eprintln!("Error: {}", e),
}
}Implementations§
Source§impl SubscriptionManager
impl SubscriptionManager
Sourcepub async fn next(&mut self) -> Option<Result<ChangeEvent, KalamLinkError>>
pub async fn next(&mut self) -> Option<Result<ChangeEvent, KalamLinkError>>
Receive the next change event from the subscription.
Returns None when the connection is closed.
Sourcepub fn subscription_id(&self) -> &str
pub fn subscription_id(&self) -> &str
Get the subscription ID assigned by the server
Sourcepub fn timeouts(&self) -> &KalamLinkTimeouts
pub fn timeouts(&self) -> &KalamLinkTimeouts
Get the configured timeouts
Sourcepub async fn close(&mut self) -> Result<(), KalamLinkError>
pub async fn close(&mut self) -> Result<(), KalamLinkError>
Close the subscription gracefully.
Safe to call multiple times — subsequent calls are no-ops.
Trait Implementations§
Source§impl Drop for SubscriptionManager
impl Drop for SubscriptionManager
Auto Trait Implementations§
impl Freeze for SubscriptionManager
impl RefUnwindSafe for SubscriptionManager
impl Send for SubscriptionManager
impl Sync for SubscriptionManager
impl Unpin for SubscriptionManager
impl UnsafeUnpin for SubscriptionManager
impl UnwindSafe for SubscriptionManager
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