Skip to content
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

Simplify transport usage in Secure Session (T963) #373

Merged
merged 1 commit into from
Feb 11, 2019

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Feb 11, 2019

Using generics avoids type erasure for SecureSessionTransport impl. This has its efficiency merits but they are quite negligible given the amount of checks and marshaling that we perform. On the other
hand, generics tend to "poison" the code with unnecessary <T>s which is not good for readability.

Replace generics and static dispatch with a trait object and dynamic dispatch. Note that user_context in C still keeps a pointer to an intermediate Rust struct. We have to use a struct because it is not possible to cast &mut dyn SecureSessionTransport as void*: trait objects are fat pointers in Rust.

While we're here, rename "delegate" into "context" (it's not only delegate) and "session_ctx" into just "session" to avoid confusion.

And really, mark unsafe functions as unsafe. They are used in unsafe blocks anyway.

Using generics avoids type erasure for SecureSessionTransport impl.
This has its efficiency merits but they are quite negligible given
the amount of checks and marshalling that we perform. On the other
hand, generics tend to "poison" the code with unnecessary "<T>"s
which is not good for readability.

Replace generics and static dispatch with a trait object and dynamic
dispatch. Note that "user_context" in C still keeps a pointer to an
intermediate Rust struct. We have to use a struct because it is not
possible to cast "&mut dyn SecureSessionTransport" as "void*": trait
objects are fat pointers in Rust.

While we're here, rename "delegate" into "context" (it's not *only*
delegate) and "session_ctx" into just "session" to avoid confusion.

And really, mark unsafe functions as unsafe. They are used in unsafe
blocks anyway.
@ilammy ilammy added the W-RustThemis 🦀 Wrapper: Rust-Themis, Rust API, Cargo crates label Feb 11, 2019
@ilammy ilammy merged commit 37cb28a into cossacklabs:master Feb 11, 2019
@ilammy ilammy deleted the ssession-ownership branch February 11, 2019 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
W-RustThemis 🦀 Wrapper: Rust-Themis, Rust API, Cargo crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants