Permalink
Browse files

Simplify transport usage in Secure Session (#373)

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.
  • Loading branch information...
ilammy committed Feb 11, 2019
1 parent a3f9659 commit 37cb28aa6f94c421423353ba460a4bd218519d2a
Showing with 116 additions and 134 deletions.
  1. +116 −134 src/wrappers/themis/rust/src/secure_session.rs
Oops, something went wrong.

0 comments on commit 37cb28a

Please sign in to comment.