radicle: fix build when schemars feature is not enabled

Commit b608a788 (cli: `rad config schema` emits JSON Schema, 2025-04-28)
added a feature flag that enables the "schemars" optional dependency.

Crate radicle-node doesn't use this feature.
Crate radicle fails to compile when the feature is disabled.
This is reproducible with "flake check".
Fix it. 

Note that a "cargo build" of the entire workspace doesn't fail, because the
feature is enabled due to "unification", since "radicle-cli" does use this
feature.  From https://doc.rust-lang.org/cargo/reference/resolver.html#features:

> When building multiple packages in a workspace (such as with --workspace
> or multiple -p flags), the features [of the dependencies] of all of those
> packages are unified. If you have a circumstance where you want to avoid
> that unification for different workspace members, you will need to build
> them via separate cargo invocations.
This commit is contained in:
Johannes Altmanninger 2025-05-24 18:39:32 +02:00
parent 1a67ac18f3
commit 059c804588
2 changed files with 4 additions and 4 deletions

View File

@ -298,7 +298,7 @@ impl Default for RateLimits {
)] )]
pub struct ConnectAddress( pub struct ConnectAddress(
#[serde(with = "crate::serde_ext::string")] #[serde(with = "crate::serde_ext::string")]
#[schemars( #[cfg_attr(feature = "schemars", schemars(
with = "String", with = "String",
regex(pattern = r"^.+@.+:((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$"), regex(pattern = r"^.+@.+:((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$"),
extend("examples" = [ extend("examples" = [
@ -307,7 +307,7 @@ pub struct ConnectAddress(
"z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@seed.example.com:8776", "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@seed.example.com:8776",
"z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5@192.0.2.0:31337", "z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5@192.0.2.0:31337",
]), ]),
)] ))]
PeerAddr<NodeId, Address>, PeerAddr<NodeId, Address>,
); );

View File

@ -1,5 +1,4 @@
use crate::prelude::RepoId; use crate::prelude::RepoId;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashSet; use std::collections::HashSet;
@ -30,8 +29,9 @@ pub struct Config {
/// Pinned content. This can be used to pin certain content when /// Pinned content. This can be used to pin certain content when
/// listing, e.g. pin repositories on a web client. /// listing, e.g. pin repositories on a web client.
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Pinned { pub struct Pinned {
/// Pinned repositories. /// Pinned repositories.
pub repositories: HashSet<RepoId>, pub repositories: HashSet<RepoId>,