aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/reader.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/reader.rs b/src/reader.rs
index 751ee1d..a46c66b 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -1,4 +1,3 @@
-#[cfg(target_arch = "wasm32")]
use std::io::Write;
use circular::Buffer;
@@ -149,6 +148,15 @@ impl Readable for WebSocketOnMessageRead {
}
}
+pub struct ReadableString(pub String);
+
+impl Readable for ReadableString {
+ async fn read_buf(&mut self, buffer: &mut Buffer) -> Result<usize> {
+ let string = self.0.split_off(0);
+ Ok(buffer.write(string.as_bytes())?)
+ }
+}
+
pub trait Readable {
fn read_buf(&mut self, buffer: &mut Buffer)
-> impl std::future::Future<Output = Result<usize>>;