Skip to content

Bad/redundant methods for Blob #1693

Open
@Pauan

Description

@Pauan

Right now there's a whole bunch of methods for creating a new Blob:

new_with_buffer_source_sequence
new_with_u8_array_sequence
new_with_blob_sequence
new_with_str_sequence
new_with_buffer_source_sequence_and_options
new_with_u8_array_sequence_and_options
new_with_blob_sequence_and_options
new_with_str_sequence_and_options

These multiple methods exist because new Blob accepts multiple different types, and so web-sys generates one method per type.

However, these multiple methods are completely useless, because they all compile down to new Blob on the JS side, and they have the same type on the Rust side. This has caused confusion for users.

I see two options:

  1. Remove them and just have two methods: Blob::new_with_array and Blob::new_with_array_and_options which accept &Array

  2. Keep them but change their type to be more useful. For example, new_with_u8_array_sequence could accept a &[u8], new_with_blob_sequence could accept a &Blob, etc.

    Because new Blob accepts 14 different Rust types, that would mean we would need 28 different methods with this approach.

I personally lean toward option 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeTracking breaking changes for the next major version bump (if ever)web-sysIssues related to the `web-sys` crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions