openwallet-foundation-labs / tsp

Apache License 2.0
6 stars 3 forks source link

Remove unnecessary copies in the Rust interface #41

Closed tweedegolf-marc closed 3 months ago

tweedegolf-marc commented 3 months ago

At some point, the data that was received was copied; either when receiving or when unpacking a nested message.

In this latter point (since encryption/decryption can happen in-place), that was unfortunate. But even in other scenarios not needlessly duplicating the payload data (which after all might be large) is a good idea.

tweedegolf-marc commented 3 months ago

Note: since this PR touches a lot of things, the individual commits separate out the various changes in a better way. Still brooding on a way to remove a copy in the async reception case. Also added a feature flag that eliminates all copies in the pure Rust interface. Perhaps that should be the default, but the solution should be tested in combat a bit better to see if there's any major interface changes.

In hindsight, it would have been better to use ranges + objects instead of Rust slices.

These mentioned changes are in PR #44 which can be merged into this one.