Skip to content

Make serde, toml deps optional - #310

Merged
jxs merged 1 commit into
rust-db:mainfrom
vasilakisfil:serde-toml-as-default-features
Feb 15, 2024
Merged

jxs merged 1 commit into
rust-db:mainfrom
vasilakisfil:serde-toml-as-default-features

Conversation

@vasilakisfil

Copy link
Copy Markdown
Contributor

We make serde and toml dependencies optional, enabled by default, using default features.

Config1 already allows to configure it programmatically, using the set_xxx methods. However, refinery-core (used by refinery crate) uses serde by default to support serialization and deserialization of this type. This is unnecessary if one doesn't need the refinery-cli and also configures it programmatically.

On top of that, refinery makes the assumption that Toml format will be used to deserialize/serialize this type, as toml dependency is used as well in refinery-core by default. Again it's not always the case, this is more related with refinery-cli.

Let's declare both serde and toml dependencies as optional, under a feature flag. Apparently, if toml dependency is enabled, serde should be enabled as well, thus toml feature enables serde feature automatically.

For refinery-cli, we just make sure to enable toml (and consequently serde) feature when using the refinery dependency, since it's impossible fo refinery-cli to work without these 2 dependencies.

However, for refinery, we declare them under the default features: they will be enabled by default, unless the host crate specifies default-features = false.

Fixes #308.

Footnotes

  1. https://docs.rs/refinery/latest/refinery/config/struct.Config.html ↩

We make `serde` and `toml` dependencies optional, enabled by default,
using default features.

Config[^1] already allows to configure it programmatically, using the
`set_xxx` methods. However, refinery-core (used by refinery crate)
uses serde by default to support serialization and deserialization of
this type. This is unnecessary if one doesn't need the `refinery-cli`
and also configures it programmatically.

On top of that, refinery makes the assumption that `Toml` format will
be used to deserialize/serialize this type, as toml dependency is used
as well in refinery-core by default. Again it's not always the case,
this is more related with `refinery-cli`.

Let's declare both `serde` and `toml` dependencies as optional, under
a feature flag. Apparently, if `toml` dependency is enabled, `serde`
should be enabled as well, thus `toml` feature enables `serde` feature
automatically.

For `refinery-cli`, we just make sure to enable `toml` (and
consequently `serde`) feature when using the `refinery` dependency,
since it's impossible fo `refinery-cli` to work without these 2
dependencies.

However, for `refinery`, we declare them under the default features:
they will be enabled by default, unless the host crate specifies
`default-features = false`.

Fixes rust-db#308.

[^1]: https://docs.rs/refinery/latest/refinery/config/struct.Config.html

@jxs jxs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! ❤️ And I am sorry for the delay reviewing it

@jxs
jxs merged commit d4e9449 into rust-db:main Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serde properties of Config should be under a feature gate along with Toml serde impl

2 participants