Skip to content

Conversation

@urlyy
Copy link
Contributor

@urlyy urlyy commented Nov 15, 2025

What does this PR do?

Add a Config struct and a global variable DEFAULT_CONFIG to manage the default configuration values for Fory.

Related issues

#2915

Does this PR introduce any user-facing change?

Like this, users can get/set default config.

use fory_core::{
    fory::{get_default_config, set_default_config, Config},
    Fory,
};

#[test]
fn test_config() {
    let default_cfg = get_default_config();
    assert_eq!(default_cfg.compatible, false);
    let compatible = true;
    let new_cfg = Config {
        compatible,
        ..default_cfg
    };
    set_default_config(new_cfg);
    let fory = Fory::default();
    assert_eq!(fory.is_compatible(), compatible);
}

@urlyy urlyy changed the title feat(rust): support global_default_config feat(rust): support default_config Nov 15, 2025
@urlyy
Copy link
Contributor Author

urlyy commented Dec 1, 2025

Has this already been implemented in #2947? Should I close this PR now?

@chaokunyang
Copy link
Collaborator

@urlyy How about rewrite this PR to create a ForyBuilder? We keep current default() and set methods, but also provide a ForyBuilder API, users can use builder instance to share similair config.

@chaokunyang
Copy link
Collaborator

And please make build() method return Result, so in future we can add some congiuration validation.

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.

2 participants