From 161eeb7be992b324248234838ae2187b06ec19ad Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Mon, 1 Jul 2024 20:52:57 -0400 Subject: [PATCH] rpc: add/doc feature flags --- rpc/types/Cargo.toml | 11 ++++++++--- rpc/types/README.md | 15 ++++++++++++++- rpc/types/src/lib.rs | 7 +++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/rpc/types/Cargo.toml b/rpc/types/Cargo.toml index 30e4aa9..ac5e15e 100644 --- a/rpc/types/Cargo.toml +++ b/rpc/types/Cargo.toml @@ -9,14 +9,19 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/rpc/types" keywords = ["cuprate", "rpc", "types", "monero"] [features] -default = [] +default = ["json", "bin", "other", "serde", "epee"] +json = [] +bin = [] +other = [] +serde = ["dep:serde"] +epee = ["dep:cuprate-epee-encoding"] [dependencies] -cuprate-epee-encoding = { path = "../../net/epee-encoding" } +cuprate-epee-encoding = { path = "../../net/epee-encoding", optional = true } monero-serai = { workspace = true } paste = { workspace = true } -serde = { workspace = true } +serde = { workspace = true, optional = true } [dev-dependencies] serde_json = { workspace = true } diff --git a/rpc/types/README.md b/rpc/types/README.md index 65b6d90..ee74d30 100644 --- a/rpc/types/README.md +++ b/rpc/types/README.md @@ -59,4 +59,17 @@ values inside JSON strings, for example: `binary` here is (de)serialized as a normal [`String`]. In order to be clear on which fields contain binary data, the struct fields that have them will use [`crate::BinaryString`] instead of [`String`]. -TODO: list the specific types. \ No newline at end of file +TODO: list the specific types. + +# Feature flags +List of feature flags for `cuprate-rpc-types`. + +All are enabled by default. + +| Feature flag | Does what | +|--------------|-----------| +| `json` | Enables the [`crate::json`] module +| `bin` | Enables the [`crate::bin`] module +| `other` | Enables the [`crate::other`] module +| `serde` | Implements `serde` on all types +| `epee` | Implements `epee_encoding` on all types \ No newline at end of file diff --git a/rpc/types/src/lib.rs b/rpc/types/src/lib.rs index 780208b..dc58ea9 100644 --- a/rpc/types/src/lib.rs +++ b/rpc/types/src/lib.rs @@ -1,4 +1,5 @@ #![doc = include_str!("../README.md")] +#![cfg_attr(docsrs, feature(doc_cfg))] //---------------------------------------------------------------------------------------------------- Lints // Forbid lints. // Our code, and code generated (e.g macros) cannot overrule these. @@ -111,6 +112,12 @@ pub use constants::{ pub use status::Status; pub mod base; +#[cfg(feature = "bin")] +#[cfg_attr(docsrs, doc(cfg(feature = "bin")))] pub mod bin; +#[cfg(feature = "json")] +#[cfg_attr(docsrs, doc(cfg(feature = "json")))] pub mod json; +#[cfg(feature = "other")] +#[cfg_attr(docsrs, doc(cfg(feature = "other")))] pub mod other;