Decide how to handle stringified booleans in configuration #2

Open
opened 2025-10-03 22:34:52 +02:00 by federico · 1 comment
Collaborator

src/core/config/settings.rs has these:

pub struct Global {
    pub render_on_save: bool,
    pub external_api: bool,
    pub dynamic_render: bool,
    ...
}

pub struct GlobalEdit {
    pub render_on_save: String,
    pub external_api: String,
    pub dynamic_render: String,
    ...
}

GlobalEdit's values later get merged into Global. Those String values get booleanified like this:

current.global.render_on_save = edit.global.render_on_save == "true";

@ro mentioned that they are strings in the JSON to be able to accept configuration files that come from the PHP verison of Fipamo.

Serde can be told to treat those fields specially, and to be able to parse them as booleans or as strings. Should I just make it do that? Are there any other considerations for being able to reuse configurations from the PHP Fipamo?

`src/core/config/settings.rs` has these: ```rust pub struct Global { pub render_on_save: bool, pub external_api: bool, pub dynamic_render: bool, ... } pub struct GlobalEdit { pub render_on_save: String, pub external_api: String, pub dynamic_render: String, ... } ``` `GlobalEdit`'s values later get merged into `Global`. Those `String` values get booleanified like this: ```rust current.global.render_on_save = edit.global.render_on_save == "true"; ``` @ro mentioned that they are strings in the JSON to be able to accept configuration files that come from the PHP verison of Fipamo. Serde can be told to treat those fields specially, and to be able to parse them as booleans or as strings. Should I just make it do that? Are there any other considerations for being able to reuse configurations from the PHP Fipamo?
Collaborator

Yeah, sounds good to me.

I did that because my knowledge of Rust is still limited, so it's just a patch.

Yeah, sounds good to me. I did that because my knowledge of Rust is still limited, so it's just a patch.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: projects/love_fipamo#2
No description provided.