Expand description
Amplifying Rust language capabilities: multiple generic trait implementations, type wrappers, derive macros.
Minimum supported rust compiler version (MSRV): 1.46 (stable channel)
Re-exports§
Modules§
- confinement
- Confinement puts a constraint on the number of elements within a collection.
- flags
- Types for building flag-based APIs and functionality
- hex
- Hex encoding and decoding
- num
- Custom-sized numeric types
- strategy
- This is a trick for rust compiler helping to distinguish types implementing mutually-exclusive traits (required until negative trait impls will be there) Implemented after concept by Martin Habovštiak martin.habovstiak@gmail.com
Macros§
- bmap
- Macro for creating
alloc::collections::BTreeMapin the same manner asvec!is used forVec: - bset
- Macro for creating
alloc::collections::BTreeSetin the same manner asvec!is used forVec: - confined_
blob Deprecated - Helper macro to construct confined blob
- confined_
bmap Deprecated - Helper macro to construct confined
BTreeMapof a given type - confined_
bset Deprecated - Helper macro to construct confined
BTreeSetof a given type - confined_
map Deprecated - Helper macro to construct confined
HashMapof a given type - confined_
s Deprecated - Helper macro to construct confined string
- confined_
set Deprecated - Helper macro to construct confined
HashSetof a given type - confined_
vec Deprecated - Helper macro to construct confined vector of a given type
- default
- Shorthand for
Default::default() - dumb
- Shorthand for
Dumb::dumb() - empty
- This macro allows more semantically-clear code (which can be used especially with structure initialization), indicating that instead of type value we are generating empty collection types
- list
- Macro for creating
alloc::collections::LinkedListin the same manner asvec!is used forVec: - map
- Macro for creating
std::collections::HashMapin the same manner asvec!is used forVec: - medium_
blob - Helper macro to construct confined blob of a
MediumBlobtype - medium_
bmap - Helper macro to construct confined
BTreeMapof aMediumOrdMaptype - medium_
bset - Helper macro to construct confined
BTreeSetof aMediumOrdSettype - medium_
map - Helper macro to construct confined
HashMapof aMediumHashMaptype - medium_
s - Helper macro to construct confined string of a
MediumStringtype - medium_
set - Helper macro to construct confined
HashSetof aMediumHashSettype - medium_
vec - Helper macro to construct confined vector of a
MediumVectype - none
- This macro allows more semantically-clear code (which can be used especially with structure initialization), indicating that instead of type value we are generating no value at all (empty collection or data structure filled with information indicating absence of data)
- s
- Macro for quick & simple
&str->Stringconversion: - set
- Macro for creating
std::collections::HashSetin the same manner asvec!is used forVec: - small_
blob - Helper macro to construct confined blob of a
SmallBlobtype - small_
bmap - Helper macro to construct confined
BTreeMapof aSmallOrdMaptype - small_
bset - Helper macro to construct confined
BTreeSetof aSmallOrdSettype - small_
map - Helper macro to construct confined
HashMapof aSmallHashMaptype - small_s
- Helper macro to construct confined string of a
SmallStringtype - small_
set - Helper macro to construct confined
HashSetof aSmallHashSettype - small_
vec - Helper macro to construct confined vector of a
SmallVectype - tiny_
blob - Helper macro to construct confined blob of a
TinyBlobtype - tiny_
bmap - Helper macro to construct confined
BTreeMapof aTinyOrdMaptype - tiny_
bset - Helper macro to construct confined
BTreeSetof aTinyOrdSettype - tiny_
map - Helper macro to construct confined
HashMapof aTinyHashMaptype - tiny_s
- Helper macro to construct confined string of a
TinyStringtype - tiny_
set - Helper macro to construct confined
HashSetof aTinyHashSettype - tiny_
vec - Helper macro to construct confined vector of a
TinyVectype - zero
- This macro allows more semantically-clear code (which can be used especially with structure initialization), indicating that instead of type value we are generating zero values (int types or byte slices filled with zeros)
Structs§
- Array
- Wrapper type for all fixed arrays implementing many important traits, so types based on it can simply derive their implementations.
- Confined
Io - Errors with
io::ErrorKind::UnexpectedEofonio::Readandio::Writeoperations if theLIMis reached. - FlagRef
- Keeps a reference to a specific feature flag within
FlagVecvector - FlagVec
- Bit flag vector. Can hold up to 2^16-1 flags and guaranteed to have length up to 255 bytes.
- From
Slice Error - Error when slice size mismatches array length.
- IoError
- Copyable & cloneable I/O error type represented by the error kind function.
- Write
Counter - A simple way to count bytes written through
io::Write.
Enums§
Traits§
- AsAny
- Trait
AsAnyallows simple conversion of any type into a generic “thick” pointer&dyn Any(seeAny), that can be later converted back to the original type with a graceful failing for all other conversions. For simple conversions it is recommended to use#[derive(AsAny)]macro fromamplify_derivecrate (seeamplify_derive::AsAny). - Byte
Array - Trait which does a blanket implementation for all types wrapping
Arrays - Dumb
- Used as an alternative to default for test and prototyping purposes, when a type can’t have a default value, but you need to generate some dumb data.
- Into
Multi Error - Join
Split - Trait for splittable streams and other types, which can be separated into
some two types (
JoinSplit::A,JoinSplit::B), like a reader and writer streams. - RawArray
Deprecated - Trait which does a blanket implementation for all types wrapping
Arrays - Wrapper
- Trait defining wrapped types (“newtypes” in rust terminology). Wrapped types are used for allowing implemeting foreign traits to foreign types: https://doc.rust-lang.org/stable/rust-by-example/generics/new_types.html
- Wrapper
Mut - Trait allowing mutable reference borrowing for the wrapped inner type.
Type Aliases§
- Bytes
- Wrapper type for all array-based bytes implementing many important traits, so types based on it can simply derive their implementations.
- Bytes4
- Wrapper type for all array-based 32-bit types implementing many important traits, so types based on it can simply derive their implementations.
- Bytes16
- Wrapper type for all array-based 128-bit types implementing many important traits, so types based on it can simply derive their implementations.
- Bytes20
- Wrapper type for all array-based 160-bit types implementing many important traits, so types based on it can simply derive their implementations.
- Bytes32
- Wrapper type for all array-based 256-bit types implementing many important traits, so types based on it can simply derive their implementations.
- Bytes64
- Wrapper type for all array-based 512-bit types implementing many important traits, so types based on it can simply derive their implementations.
- Bytes32
StrRev - Wrapper type for all array-based 256-bit types implementing many important traits, so types based on it can simply derive their implementations.
- FlagNo
- A single feature flag, represented by it’s number inside feature vector
Derive Macros§
- AsAny
- Trait
amplify::AsAnyallows simple conversion of any type into a generic “thick” pointer&dyn Any(see [::core::any::Any]), that can be later converted back to the original type with a graceful failing for all other conversions.AsAnyderive macro allows to implement this trait for arbitrary time without much hussle: - Display
- Usage
- Error
- Error derive macro works to the full extend only when other derive macros
are used. With
#[derive(Display)]and[display(doc_comments)]it uses doc comments for generating error descriptions; with#[derive(From)]it may automatically implement transofrations from other error types. - From
- Implements
Fromtrait for the whole entity and/or its separate fields. Works well with#[derive(Error)]and, in many cases may require [Default] implementation (for details, pls see Examples below) - Getters
- Derives getter methods for structures. The return type and naming of the methods depends on the provided attribute arguments.
- Wrapper
- Creates rust new type wrapping existing type. Can be used in structures
containing multiple named or unnamed fields; in this case the field you’d
like to wrap should be marked with
#[wrap]attribute; otherwise the first field is assumed to be the wrapped one. - Wrapper
Mut - Derives
WrapperMutand allows deriving other traits accessing the wrapped type which require mutable access to the inner type. Requires that the type already implementsamplify::Wrapper.