Skip to content

Implement Blob get_stream #25209

@gterzian

Description

@gterzian

Spec: https://w3c.github.io/FileAPI/#blob-get-stream

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:

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions