mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-30 11:12:58 +00:00
serverless/rust: narrow the wasm response stream cfg to the target arch
Every wasm32 target that can use reqwest goes through the wasm-bindgen browser backend, so testing target_os on top of target_arch never changes the outcome and only makes the two aliases harder to read. Also keep the LineReader doc comment attached to LineReader: the aliases were inserted between the comment and the struct, so the comment had started documenting the alias instead. Tests: - cargo fmt --check -p turso_serverless - cargo clippy -p turso_serverless --all-targets - cargo test -p turso_serverless --lib - cargo check -p turso_serverless --target wasm32-unknown-unknown
This commit is contained in:
@@ -63,14 +63,15 @@ pub struct Session {
|
||||
pub shared: Arc<SharedState>,
|
||||
}
|
||||
|
||||
/// Reads newline-separated JSON values from a cursor response body
|
||||
/// (section 7.2).
|
||||
#[cfg(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))))]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
type ResponseStream = Pin<Box<dyn futures::Stream<Item = reqwest::Result<bytes::Bytes>> + Send>>;
|
||||
|
||||
#[cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))]
|
||||
/// On wasm32 the response body is a JavaScript `ReadableStream`, which is not `Send`.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
type ResponseStream = Pin<Box<dyn futures::Stream<Item = reqwest::Result<bytes::Bytes>>>>;
|
||||
|
||||
/// Reads newline-separated JSON values from a cursor response body
|
||||
/// (section 7.2).
|
||||
struct LineReader {
|
||||
stream: ResponseStream,
|
||||
buf: Vec<u8>,
|
||||
|
||||
Reference in New Issue
Block a user