Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add comments for typing #20

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/warp/constellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ impl ConstellationBox {
.map(|ok| ok.to_vec())
}

/// Returns a progression stream
/// The result of the stream is of type {@link Progression}
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/raygun/mod.rs#L306
pub async fn put_stream(
&mut self,
name: &str,
Expand All @@ -107,6 +110,8 @@ impl ConstellationBox {
})
}

/// Returns a file stream
/// Each stream element is a byte array chunk of the file
pub async fn get_stream(&self, name: &str) -> Result<AsyncIterator, JsError> {
self.inner
.get_stream(name)
Expand Down
3 changes: 3 additions & 0 deletions src/warp/multipass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ impl MultiPassBox {
/// impl MultiPassEvent trait
#[wasm_bindgen]
impl MultiPassBox {
/// Subscribe to multipass events returning a stream of multipass events
/// The result is of type warp::multipass::MultiPassEventKind
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/multipass/mod.rs#L28
pub async fn multipass_subscribe(&mut self) -> Result<AsyncIterator, JsError> {
self.inner
.multipass_subscribe()
Expand Down
14 changes: 14 additions & 0 deletions src/warp/raygun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl RayGunBox {
}

/// Retrieve all message references from a conversation
/// Stream values are {@link MessageReference}
pub async fn get_message_references(
&self,
conversation_id: String,
Expand Down Expand Up @@ -487,6 +488,7 @@ impl RayGunBox {

/// Stream a file that been attached to a message
/// Note: Must use the filename associated when downloading
/// Async results are a byte array
pub async fn download_stream(
&self,
conversation_id: String,
Expand Down Expand Up @@ -517,6 +519,8 @@ impl RayGunBox {
#[wasm_bindgen]
impl RayGunBox {
/// Subscribe to an stream of events from the conversation
/// Async results are of type MessageEventKind
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/raygun/mod.rs#L47
pub async fn get_conversation_stream(
&mut self,
conversation_id: String,
Expand All @@ -533,6 +537,8 @@ impl RayGunBox {
}

/// Subscribe to an stream of events
/// Async results are of type RayGunEventKind
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/raygun/mod.rs#L33
pub async fn raygun_subscribe(&mut self) -> Result<AsyncIterator, JsError> {
self.inner
.raygun_subscribe()
Expand All @@ -549,6 +555,8 @@ impl RayGunBox {
/// impl RayGunCommunity trait
#[wasm_bindgen]
impl RayGunBox {
/// Async results are of type MessageEventKind
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/raygun/mod.rs#L47
pub async fn get_community_stream(
&mut self,
community_id: String,
Expand Down Expand Up @@ -1101,6 +1109,7 @@ impl RayGunBox {
.map_err(|e| e.into())
.map(|inner| MessageReference { inner })
}
/// Stream values are {@link MessageReference}
pub async fn get_community_channel_message_references(
&self,
community_id: String,
Expand Down Expand Up @@ -1460,6 +1469,8 @@ impl Messages {
}
}
/// Return the next element of the stream if this is a stream variant
/// Async results are of type warp::raygun::Message
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/raygun/mod.rs#L1076
pub async fn next_stream(&mut self) -> std::result::Result<Promise, JsError> {
if let Some(s) = self.stream.as_mut() {
return s.next().await;
Expand Down Expand Up @@ -1762,6 +1773,9 @@ impl AttachmentResult {
self.message_id.clone()
}

/// Returns the next progress
/// The result is of type warp::raygun::AttachmentKind
/// See https://github.com/Satellite-im/Warp/blob/main/warp/src/raygun/mod.rs#L306
pub async fn next(&mut self) -> std::result::Result<Promise, JsError> {
self.stream.next().await
}
Expand Down
3 changes: 3 additions & 0 deletions src/warp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::task::{Context, Poll};
use wasm_bindgen::prelude::*;

/// Wraps BoxStream<'static, TesseractEvent> into a js compatible struct
/// Currently there is no generic way for this so on JS-side this returns any
#[wasm_bindgen]
pub struct AsyncIterator {
inner: BoxStream<'static, JsValue>,
Expand All @@ -18,6 +19,8 @@ impl AsyncIterator {
/// Provides the next() function expected by js async iterator
#[wasm_bindgen]
impl AsyncIterator {
/// Next value in this iterator. Due to wasm limitations can only return any type
/// Refer to implementations for more info
pub async fn next(&mut self) -> std::result::Result<Promise, JsError> {
let next = self.inner.next().await;
match next {
Expand Down
Loading