You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define or create required trait or traits for every major allocating type category (Box, Vec, String, Bytes, etc.)
These would need to handle creation, mutation and usage (within Buffa)
Implement only stdlib types (String, Vec, Box) and/or common 3rd party types (Bytes, etc.) in Buffa itself
Default to these implementations, but allow override via build.rs via API or buf via string options
Why?
Creates a universal mechanism for crate authors to implement Buffa support without Buffa authors constantly having to implement new feature requests for new types
Applies to all allocated types, not just strings, since a user's allocation stress points and security needs are going to vary
Allows users to create their own wrapper types for types where crate authors choose not to implement Buffa support
Allows users to control things like allocation and security (Zeroize on Drop) based on their needs without involving Buffa authors
Increases Buffa's theoretical top end performance by optionally removing many allocations from encode/decode path
Examples:
FlexStr (String replacement) - not only supports ref counted and inline strings, but also zeroize on drop for security
Disclaimer: I am the author and maintainer of this crate
SmallBox (Box replacement) - supports inline boxed values up to a certain size then falls back to heap
SmallVec (Vec Replacement) - supports inline vec values up to a certain size then falls back to heap
SmallBytes (Bytes replacement) - wrapper over Smallvec for Bytes-like support
Challenges:
Naming the type - some of these types take multiple generic parameters, but only one of those needs dynamic replacement when used in a struct
Option: user supplies a type as a string with optional wildcard and Buffa parses the string into a full type: e.g. smallbox::SmallBox<*, S4> (where the * is replaced by whatever type you need in the box)
How It Works
Box,Vec,String,Bytes, etc.)Buffa)String,Vec,Box) and/or common 3rd party types (Bytes, etc.) inBuffaitselfbuild.rsvia API orbufvia string optionsWhy?
Buffasupport withoutBuffaauthors constantly having to implement new feature requests for new typesSmallBoxsupports optional inline allocation without changing your existing boxing logicBuffato be aware of these types at all, as well as need to stay up to date on their interface versioningsmol_str::SmolStr), mirroring use_bytes_type #127, and users can choose any string type that conforms to your trait definitionsBuffasupportBuffaauthorsBuffa's theoretical top end performance by optionally removing many allocations from encode/decode pathExamples:
Stringreplacement) - not only supports ref counted and inline strings, but also zeroize on drop for securityBoxreplacement) - supports inline boxed values up to a certain size then falls back to heapVecReplacement) - supports inline vec values up to a certain size then falls back to heapBytesreplacement) - wrapper overSmallvecforBytes-like supportChallenges:
Buffaparses the string into a full type: e.g.smallbox::SmallBox<*, S4>(where the*is replaced by whatever type you need in the box)