57 releases (26 stable)

new 2.13.0 Mar 28, 2024
2.11.1 Jan 31, 2024
2.10.2 Oct 19, 2023
2.6.1 Jun 27, 2023
0.0.4 Dec 6, 2018

#11 in #sval

Download history 94/week @ 2023-12-06 205/week @ 2023-12-13 76/week @ 2023-12-20 80/week @ 2023-12-27 112/week @ 2024-01-03 93/week @ 2024-01-10 108/week @ 2024-01-17 178/week @ 2024-01-24 146/week @ 2024-01-31 288/week @ 2024-02-07 400/week @ 2024-02-14 326/week @ 2024-02-21 422/week @ 2024-02-28 213/week @ 2024-03-06 440/week @ 2024-03-13 386/week @ 2024-03-20

1,575 downloads per month
Used in 3 crates (2 directly)

Apache-2.0 OR MIT

40KB
936 lines

sval_derive

Rust Latest version Documentation Latest

Automatically derive sval::Value.


lib.rs:

#![derive(Value)].

This library hosts a custom-derive to simplify implementing sval::Value.

Structs

Container attributes:

  • #[sval(tag = "path::to::TAG")]: Set a tag on the struct. No tag is used by default.
  • #[sval(label = "text")]: Set a label on the struct. The identifier of the struct is used by default.
  • #[sval(index = 1)]: Set an index on the struct. No index is used by default.
  • #[sval(unlabeled_fields)]: Specify that all fields should be unlabeled. This will stream the struct as a tuple. If #[sval(unindexed_fields)] is also specified then it will stream the struct as a sequence.
  • #[sval(unindexed_fields]: Specify that all fields should be unindexed. This will stream the struct as a record. If #[sval(unlabeled_fields)] is also specified then it will stream the struct as a sequence.

Field attributes:

  • #[sval(tag = "path::to::TAG")]: Set a tag on the struct field itself. No tag is used by default. If you want to use a tag to signal that the field's value has a particular property then use #[sval(data_tag)].
  • #[sval(data_tag = "path::to::TAG")]: Set a tag on the struct field's value. No tag is used by default.
  • #[sval(label = "text")]: Set a label on the struct field. The identifier of the field is used by default.
  • #[sval(index = 1)]: Set an index on the struct field. The zero-based offset of the field is used by default.
  • #[sval(skip)]: Skip a field.
  • #[sval(flatten)]: Flatten the field onto the struct. This attribute requires the flatten Cargo feature.

Newtypes

Container attributes:

  • #[sval(tag = "path::to::TAG")]: Set a tag on the newtype. No tag is used by default.
  • #[sval(label = "text")]: Set a label on the newtype. The identifier of the newtype is used by default.
  • #[sval(index = 1)]: Set an index on the newtype. No index is used by default.
  • #[sval(transparent)]: Stream the newtype as its underlying field without wrapping it.

Enums

Container attributes:

  • #[sval(tag = "path::to::TAG")]: Set a tag on the enum. No tag is used by default.
  • #[sval(label = "text")]: Set a label on the enum. The identifier of the enum is used by default.
  • #[sval(index = 1)]: Set an index on the enum. No index is used by default.
  • #[sval(dynamic)]: Stream the variant without wrapping it in an enum.

Variant attributes:

  • #[sval(tag = "path::to::TAG")]: Set a tag on the enum variant itself. No tag is used by default.
  • #[sval(label = "text")]: Set a label on the enum variant. The identifier of the variant is used by default.
  • #[sval(index = 1)]: Set an index on the enum variant. The zero-based offset of the variant is used by default.

Dependencies

~0.3–0.8MB
~19K SLoC