Skip to content

Commit f05e0dc

Browse files
committed
server: remove rustls_result from set_persistence
Previously `rustls_server_config_builder_set_persistence()` returned a `rustls_result` just to indicate if a required parameter was `NULL`. Our API guidelines instead recommend this function do nothing and return void for these circumstances.
1 parent c5ff8e1 commit f05e0dc

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

librustls/src/rustls.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,13 +2428,16 @@ rustls_result rustls_client_hello_select_certified_key(const struct rustls_clien
24282428
* keys and values are highly sensitive data, containing enough information
24292429
* to break the security of the connections involved.
24302430
*
2431+
* If `builder`, `get_cb`, or `put_cb` are NULL, this function will return
2432+
* immediately without doing anything.
2433+
*
24312434
* If `userdata` has been set with rustls_connection_set_userdata, it
24322435
* will be passed to the callbacks. Otherwise the userdata param passed to
24332436
* the callbacks will be NULL.
24342437
*/
2435-
rustls_result rustls_server_config_builder_set_persistence(struct rustls_server_config_builder *builder,
2436-
rustls_session_store_get_callback get_cb,
2437-
rustls_session_store_put_callback put_cb);
2438+
void rustls_server_config_builder_set_persistence(struct rustls_server_config_builder *builder,
2439+
rustls_session_store_get_callback get_cb,
2440+
rustls_session_store_put_callback put_cb);
24382441

24392442
/**
24402443
* Free a `rustls_client_cert_verifier` previously returned from

librustls/src/server.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ impl rustls_server_config {
443443
}
444444
}
445445

446-
447446
/// Returns a `rustls_str` reference to the server name sent by the client in a server name
448447
/// indication (SNI) extension.
449448
///
@@ -722,6 +721,9 @@ impl rustls_server_config_builder {
722721
/// keys and values are highly sensitive data, containing enough information
723722
/// to break the security of the connections involved.
724723
///
724+
/// If `builder`, `get_cb`, or `put_cb` are NULL, this function will return
725+
/// immediately without doing anything.
726+
///
725727
/// If `userdata` has been set with rustls_connection_set_userdata, it
726728
/// will be passed to the callbacks. Otherwise the userdata param passed to
727729
/// the callbacks will be NULL.
@@ -730,19 +732,17 @@ impl rustls_server_config_builder {
730732
builder: *mut rustls_server_config_builder,
731733
get_cb: rustls_session_store_get_callback,
732734
put_cb: rustls_session_store_put_callback,
733-
) -> rustls_result {
735+
) {
734736
ffi_panic_boundary! {
735-
let get_cb = match get_cb {
736-
Some(cb) => cb,
737-
None => return rustls_result::NullParameter,
737+
let Some(get_cb) = get_cb else {
738+
return;
738739
};
739-
let put_cb = match put_cb {
740-
Some(cb) => cb,
741-
None => return rustls_result::NullParameter,
740+
let Some(put_cb) = put_cb else {
741+
return;
742742
};
743-
let builder = try_mut_from_ptr!(builder);
744-
builder.session_storage = Some(Arc::new(SessionStoreBroker::new(get_cb, put_cb)));
745-
rustls_result::Ok
743+
744+
try_mut_from_ptr!(builder).session_storage =
745+
Some(Arc::new(SessionStoreBroker::new(get_cb, put_cb)));
746746
}
747747
}
748748
}

0 commit comments

Comments
 (0)