pub struct StreamHandle {
pub url: String,
pub expires_at: String,
/* private fields */
}Expand description
A live Void Stream handle. Write encrypted messages and close to self-destruct.
Fields§
§url: StringShareable URL — share this with viewers (contains the decryption key)
expires_at: StringImplementations§
Source§impl StreamHandle
impl StreamHandle
Sourcepub async fn write(&self, content: &str) -> Result<()>
pub async fn write(&self, content: &str) -> Result<()>
Encrypt content client-side and push it to the stream.
Sourcepub async fn close(&self) -> Result<()>
pub async fn close(&self) -> Result<()>
Close the stream. Viewers receive a “closed” event and all content self-destructs.
Sourcepub fn watch(&self) -> impl Stream<Item = Result<String>> + Send + 'static
pub fn watch(&self) -> impl Stream<Item = Result<String>> + Send + 'static
Watch the stream as an async Stream of decrypted messages.
Automatically reconnects using SSE Last-Event-ID until the stream
closes or expires.
ⓘ
use futures::StreamExt;
// stream is a StreamHandle from create_stream()
let mut msgs = stream.watch();
while let Some(Ok(msg)) = msgs.next().await {
println!("{msg}");
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamHandle
impl !RefUnwindSafe for StreamHandle
impl Send for StreamHandle
impl Sync for StreamHandle
impl Unpin for StreamHandle
impl UnsafeUnpin for StreamHandle
impl !UnwindSafe for StreamHandle
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