Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ serde-shape-derive = { version = "=0.0.1", path = "serde-shape-derive" }
# crates.io dependencies
clap = { version = "4.6.1" }
insta = { version = "1.48.0" }
proc-macro-crate = { version = "3.5.0" }
proc-macro2 = { version = "1.0.95" }
quote = { version = "1.0.40" }
serde = { version = "1.0.229", features = ["derive"] }
serde_derive_internals = { version = "0.29.1" }
serde_json = { version = "1.0.151" }
serde_test = { version = "1.0.177" }
syn = { version = "2.0.104" }
toml_edit = { version = "0.25.13", features = ["serde"] }
which = { version = "8.0.4" }
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ See the [crate documentation][docs-url] for the full shape graph model, derive b
- `derive`: enables `#[derive(SerializeShape)]` and `#[derive(DeserializeShape)]`.
- `std`: enables shape implementations for standard-library-only types.

## Built-in shapes

The built-in implementations follow Serde's own data-model calls in each direction.

| Group | Supported types |
| --- | --- |
| Scalars | Rust primitives, `String`, `str`, non-zero integers, and atomics available on the target |
| Containers | `Option`, `Result`, arrays, slices for serialization, tuples through arity 16, `Vec`, `VecDeque`, `LinkedList`, `BinaryHeap`, `BTreeSet`, and `BTreeMap` |
| Wrappers | References, `Box`, `Cow`, `Cell`, `RefCell`, `Wrapping`, `Reverse`, and `PhantomData` |
| Time | `core::time::Duration` |
| `std` feature | `HashMap`, `HashSet`, `Path`, `PathBuf`, IP and socket address types, `Mutex`, and `RwLock` |

Network address shapes are unions of their human-readable string representation and their compact Serde representation. A serialized byte slice is a sequence, while borrowed byte deserialization uses `ShapeRef::Bytes`.

For an unsupported foreign type, use a local newtype and implement `SerializeShape` or `DeserializeShape` manually. Custom Serde functions remain visible as opaque boundaries because their wire behavior cannot be inferred.

## `no_std` support

`serde-shape` is `no_std` by default and requires `alloc`.
Expand Down
1 change: 1 addition & 0 deletions serde-shape-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rust-version.workspace = true
proc-macro = true

[dependencies]
proc-macro-crate = { workspace = true }
proc-macro2 = { workspace = true }
quote = { workspace = true }
serde_derive_internals = { workspace = true }
Expand Down
Loading