-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api alignment: Config alignment #188
Conversation
…ig, and associating it with a native config.
- renaming Config.from to Config.fromFile - Adding tests - Adding or improving KDocs on Config
PR missing one of the required labels: breaking-change bug dependencies documentation enhancement new feature internal |
/// | ||
#[no_mangle] | ||
#[allow(non_snake_case)] | ||
pub extern "C" fn Java_io_zenoh_jni_JNIConfig_00024Companion_loadDefaultConfigViaJNI( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an automatically generated code? The names look a bit strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its not 😅 . It's strange because it's meant to be called from Kotlin through the JNI by a function named loadDefaultConfigViaJNI
located at io/zenoh/jni/JNIConfig$Companion. It must have this weird looking signature for Java/Kotlin to locate the corresponding native function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Changes:
Config.Format
enumConfig.from(string, format)
withConfig.fromJson(string)
,Config.fromJson5(string)
,Config.fromYaml(string)
, where each of these functions returns aResult<Config>
.Config.from(file)
withConfig.fromFile(File file): Result<Config>
andConfig.fromFile(Path path): Result<Config>
.Config.default()
still returns a Config (without result, as it's guaranteed it is successfully created by the library).Internally, when creating a config, the value provided is processed natively, associating each Config instance to a native config instance. The native instance of the config is freed when the Kotlin Config is garbage collected.