-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Implement Blob get_stream #25209
Description
Servo currently has a get_bytes method that roughly correspond to this, and is used in many places(for example in FileReader) in lieu of get_stream:
servo/components/script/dom/blob.rs
Line 141 in d92f705
| pub fn get_bytes(&self) -> Result<Vec<u8>, ()> { |
I think we should be able to replace the use of get_bytes with get_stream everywhere.
In at least one case, when stream() is called, the stream will be directly passed to the JS, in other cases, for example when the filereader calls get_stream directly, it would just be used from Rust.
I would say that in both cases, we can use a Rust struct that would implement ReadableStreamUnderlyingSource, and the API provides optimized access to it if no JS is involved: https://github.com/servo/mozjs/blob/e21c05b415dfc246175ff8d5fc48b0e8c5b4e9e9/mozjs/js/public/Stream.h#L185