Skip to content

Commit 68ace18

Browse files
authored
Merge pull request #241 from quark-zju/serde
Initial serde support
2 parents d77f80c + a6b1292 commit 68ace18

File tree

8 files changed

+976
-2
lines changed

8 files changed

+976
-2
lines changed

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ appveyor = { repository = "dgrunwald/rust-cpython" }
3535
libc = "0.2"
3636
num-traits = "0.2"
3737
paste = "0.1"
38+
serde = { version = "1", features = ["derive"], optional = true }
39+
40+
[dev-dependencies]
41+
serde_bytes = { version = "0.11" }
42+
serde_cbor = { version = "0.11" }
3843

3944
# These features are both optional, but you must pick one to
4045
# indicate which python ffi you are trying to bind to.
@@ -51,6 +56,9 @@ version = "0.5.1"
5156
[features]
5257
default = ["python3-sys"]
5358

59+
# Enable serde support that converts between a serde type and PyObject.
60+
serde-convert = ["serde"]
61+
5462
# Deprecated: nonnull feature no longer has any effect;
5563
# std::ptr::NonNull is now used unconditionally.
5664
nonnull = []

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ build: src/py_class/py_class_impl2.rs src/py_class/py_class_impl3.rs python27-sy
4545
cargo build $(CARGO_FLAGS)
4646

4747
test: build
48-
cargo test $(CARGO_FLAGS)
48+
cargo test --features serde-convert $(CARGO_FLAGS)
4949
ifeq ($(NIGHTLY),1)
5050
# ast-json output is only supported on nightly
5151
python$(PY) tests/check_symbols.py
5252
endif
5353

5454
doc: build
55-
cargo doc --no-deps $(CARGO_FLAGS)
55+
cargo doc --no-deps --features serde-convert $(CARGO_FLAGS)
5656

5757
extensions: build
5858
make -C extensions/tests PY=$(PY)

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ mod pythonrun;
214214
pub mod py_class;
215215
mod sharedref;
216216

217+
#[cfg(feature = "serde-convert")]
218+
pub mod serde;
219+
217220
/// Private re-exports for macros. Do not use.
218221
#[doc(hidden)]
219222
pub mod _detail {

0 commit comments

Comments
 (0)