I'm trying to deserialize a response from a fetch request in deno within Rust. I'm using serde_v8 to deserialize the response. I'm trying to deserialize the body field into a StringOrBuffer type, but have tried other types as well
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Response {
pub body: serde_v8::StringOrBuffer, // => `body` is a ReadableStream in the JS object
pub headers: Map<String, Value>,
pub status: u16,
pub status_text: ByteString,
pub url: ByteString,
pub redirected: bool,
pub ok: bool,
}
// ....
let resolved = js_runtime.resolve_value(promise).await?;
let scope = &mut js_runtime.handle_scope();
let resolved = v8::Local::<v8::Value>::new(scope, resolved);
// this throws an error as long as `body` is present in the Response struct. Works when `body` is defined as `serde_v8::Value` or not present at all.
let resolved = deno_core::serde_v8::from_v8::<Response>(scope, resolved);
My goal is, to access the body within Rust and use it for further steps.