Please sign in to comment.
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...
Showing with 116 additions and 134 deletions.
Oops, something went wrong.