feat: convert public SFrame API to use Result<T>#83
Closed
k-wasniowski wants to merge 1 commit intocisco:mainfrom
Closed
feat: convert public SFrame API to use Result<T>#83k-wasniowski wants to merge 1 commit intocisco:mainfrom
k-wasniowski wants to merge 1 commit intocisco:mainfrom
Conversation
23949f6 to
36d284f
Compare
36d284f to
1e718fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor: Convert Public SFrame API to Return
Result<T>Summary
This PR completes the migration of the SFrame public API away from exception-based error handling to the
Result<T>return type. All public methods onContextandMLSContextnow returnResult<T>instead of throwing exceptions, giving callers explicit, composable control over error propagation.This builds on the two preceding PRs that introduced
Result<T>to the crypto layer (#81) and the SFrame internals (#82).What Changed
Public API (
include/sframe/sframe.h)Every public method that previously threw exceptions now returns a
Result<T>:Context::add_keyvoid(throws)Result<void>Context::protectoutput_bytes(throws)Result<output_bytes>Context::unprotectoutput_bytes(throws)Result<output_bytes>MLSContext::add_epoch(both overloads)void(throws)Result<void>MLSContext::protect(both overloads)output_bytes(throws)Result<output_bytes>MLSContext::unprotectoutput_bytes(throws)Result<output_bytes>Private helpers were also updated:
MLSContext::form_key_idKeyID(throws)Result<KeyID>MLSContext::ensure_keyvoid(throws)Result<void>MLSContext::EpochKeysconstructorstatic Result<EpochKeys> create()factoryImplementation (
src/sframe.cpp)throwstatements in the public/private API surface replaced withreturn SFrameError(...).EpochKeysconverted from a throwing constructor to a staticcreate()factory that returnsResult<EpochKeys>.EpochKeysscalar fields now have in-class default initializers (= 0) to eliminate clang-analyzer warnings about uninitialized members in implicit constructors.How to Use the New API
Basic
ContextusageMLSContextusageError Types (
SFrameErrorType)internal_errorinvalid_parameter_errorbuffer_too_small_errorcrypto_errorunsupported_ciphersuite_errorauthentication_errorinvalid_key_usage_errorMigration Guide
If you are currently calling the SFrame API and catching exceptions: