dubbo-rs-serialization 0.1.0

Serialization abstraction for Apache Dubbo Rust — Serialization trait for wire-format encoding
Documentation
  • Coverage
  • 40%
    2 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 14.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 247.37 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • wii1980/dubbo-rs
    1 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wii1980

dubbo-rs-serialization

crates.io docs.rs Apache-2.0

Serialization abstraction for Apache Dubbo Rust — defines a Serialization trait that serves as a thin abstraction over wire-format encoding.

Installation

Add this to your Cargo.toml:

[dependencies]
dubbo-rs-serialization = "0.1"

Or use cargo add:

cargo add dubbo-rs-serialization

Key Public Types

Serialization trait

pub trait Serialization: Send + Sync {
    fn content_type(&self) -> &'static str;
    fn serialize(&self, data: &[u8]) -> Result<Vec<u8>>;
    fn deserialize(&self, data: &[u8]) -> Result<Vec<u8>>;
}
Method Description
content_type() Returns the MIME type for this serialization format
serialize(&[u8]) Encode raw bytes into wire-format payload
deserialize(&[u8]) Decode wire-format payload back to raw bytes

Re-exports

  • pub use dubbo_rs_common as common — access to URL, Node, constants, etc.

Implementations

This trait is implemented by:

  • dubbo-serialization-protobuf"application/grpc+proto" (byte pass-through)
  • dubbo-serialization-hessian2 — Hessian2 binary encoding
  • dubbo-serialization-json — JSON encoding via serde_json

Example

use dubbo_rs_serialization::Serialization;

// Implement a custom serialization
struct JsonSerialization;

impl Serialization for JsonSerialization {
    fn content_type(&self) -> &'static str { "application/json" }
    fn serialize(&self, data: &[u8]) -> anyhow::Result<Vec<u8>> { Ok(data.to_vec()) }
    fn deserialize(&self, data: &[u8]) -> anyhow::Result<Vec<u8>> { Ok(data.to_vec()) }
}

License

Apache-2.0