|
1 | | -use crate::store::body_store::{cancel_body, read_body_all, read_body_chunk}; |
| 1 | +use crate::store::body_store::{cancel_body, read_body_chunk}; |
2 | 2 | use neon::prelude::*; |
3 | 3 | use neon::types::JsBuffer; |
4 | 4 |
|
@@ -32,32 +32,13 @@ fn read_body_chunk_js(mut cx: FunctionContext) -> JsResult<JsPromise> { |
32 | 32 | Ok(promise) |
33 | 33 | } |
34 | 34 |
|
35 | | -fn read_body_all_js(mut cx: FunctionContext) -> JsResult<JsPromise> { |
36 | | - let handle = cx.argument::<JsNumber>(0)?.value(&mut cx) as u64; |
37 | | - |
38 | | - let channel = cx.channel(); |
39 | | - let (deferred, promise) = cx.promise(); |
40 | | - |
41 | | - std::thread::spawn(move || { |
42 | | - let result = read_body_all(handle); |
43 | | - |
44 | | - deferred.settle_with(&channel, move |mut cx| match result { |
45 | | - Ok(bytes) => JsBuffer::from_slice(&mut cx, &bytes), |
46 | | - Err(error) => cx.throw_error(format!("{:#}", error)), |
47 | | - }); |
48 | | - }); |
49 | | - |
50 | | - Ok(promise) |
51 | | -} |
52 | | - |
53 | 35 | fn cancel_body_js(mut cx: FunctionContext) -> JsResult<JsBoolean> { |
54 | 36 | let handle = cx.argument::<JsNumber>(0)?.value(&mut cx) as u64; |
55 | 37 | Ok(cx.boolean(cancel_body(handle))) |
56 | 38 | } |
57 | 39 |
|
58 | 40 | pub fn register(cx: &mut ModuleContext) -> NeonResult<()> { |
59 | 41 | cx.export_function("readBodyChunk", read_body_chunk_js)?; |
60 | | - cx.export_function("readBodyAll", read_body_all_js)?; |
61 | 42 | cx.export_function("cancelBody", cancel_body_js)?; |
62 | 43 | Ok(()) |
63 | 44 | } |
0 commit comments