Skip to content

Feature: BSON support for compact binary serialization #3402

Open
@pheonixfirewingz

Description

@pheonixfirewingz
  • I have looked for existing issues (including closed) about this

Feature Request

Add a BSON version of JSON serialization/deserialization support
https://docs.rs/bson/2.15.0/bson/

Motivation

I need to reduce network traffic in my application by compressing the JSON data being sent and received. BSON's binary format is significantly more compact than JSON for most data structures, which would help reduce bandwidth usage and improve response times.

JSON's text format includes a lot of redundant characters and doesn't encode numbers efficiently. BSON stores data in a binary format that's both smaller and faster to parse. This would be especially beneficial for applications sending large amounts of data or operating in bandwidth-constrained environments.

Right now, I'm stuck with verbose JSON payloads that take up unnecessary bandwidth. Having native BSON support would let me easily switch to a more efficient format without major code changes.

Proposal

Add BSON support similar to how JSON is currently handled. The implementation should use the existing bson crate and be behind an optional feature flag so it doesn't bloat the core library.

The API should feel consistent with the current JSON implementation while taking advantage of BSON's unique features. Error handling should integrate cleanly with the existing error types, and we'd need good documentation with examples showing common use cases.

Alternatives

I considered just doing the Axum-to-BSON conversion manually in my application code, but it would become a hindrance to maintain when I change between lib versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions