fluent-serde 0.1.0

Serializer implementations for FluentValue and FluentArgs
Documentation
  • Coverage
  • 73.68%
    14 out of 19 items documented3 out of 11 items with examples
  • Size
  • Source code size: 31.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 867.74 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • chitoyuu/fluent-serde
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chitoyuu

fluent-serde

Provides third-party serde implementations for fluent argument and value types.

This crate is not affiliated with Mozilla or Project Fluent in any way.

[dependencies]
fluent = "0.16.0"
fluent-serde = "0.1.0"

Example

use std::borrow::Cow;

use fluent::FluentValue;
use fluent::types::{FluentNumber, FluentNumberOptions};
use fluent_serde::ser::ArgsSerializer;
use serde::Serialize;

#[derive(Serialize)]
struct Foo {
    foo: i32,
}

#[derive(Serialize)]
struct Bar {
    bar: String,
}

let mut ser = ArgsSerializer::new();
Foo { foo: 42 }.serialize(&mut ser);
Bar { bar: "bar".into() }.serialize(&mut ser);
let args = ser.done();

assert_eq!(
    &FluentValue::Number(FluentNumber::new(42.0, FluentNumberOptions::default())),
    args.get("foo").unwrap(),
);

assert_eq!(
    &FluentValue::String(Cow::Owned("bar".into())),
    args.get("bar").unwrap(),
);

License

MIT OR Apache-2.0