Crates.io | serde_path_serializer |
lib.rs | serde_path_serializer |
version | 1.0.0 |
source | src |
created_at | 2024-08-14 11:25:40.110277 |
updated_at | 2024-08-14 11:25:40.110277 |
description | A Serde serializer for Path |
homepage | https://gogs.shadoware.org/phoenix/serde_path_serializer |
repository | https://gogs.shadoware.org/phoenix/serde_path_serializer.git |
max_upload_size | |
id | 1337155 |
size | 4,600 |
This crate provides a Path
serializer for Serde.
Add this to your Cargo.toml
:
cargo add serde_path_serializer
[dependencies]
serde_path_serializer = "0.1"
use serde_path_serializer::serialize_path;
let path = std::path::Path::new("foo/bar/baz");
let serialized = serialize_path(&path);
assert_eq!(serialized, "foo/bar/baz");
or
use serde_path_serializer::serialize_path;
use serde::Serialize;
#[derive(Serialize)]
struct MyStruct {
#[serde(serialize_with = "serialize_path")]
data: Vec<u8>,
}