[−]Trait ssb_keyfile::AsBytes
Types which are safe to treat as an immutable byte slice.
WARNING: Do not implement this trait yourself! Instead, use
#[derive(AsBytes)].
AsBytes types can be safely viewed as a slice of bytes. In particular,
this means that, in any valid instance of the type, none of the bytes of the
instance are uninitialized. This precludes the following types:
- Structs with internal padding
- Unions in which not all variants have the same length
AsBytes is ignorant of byte order. For byte order-aware types, see the
[byteorder] module.
Custom Derive Errors
Due to the way that the custom derive for AsBytes is implemented, you may
get an error like this:
error[E0080]: evaluation of constant value failed
--> lib.rs:1:10
|
1 | #[derive(AsBytes)]
| ^^^^^^^ attempt to divide by zero
This error means that the type being annotated has padding bytes, which is
illegal for AsBytes types. Consider either adding explicit struct fields
where those padding bytes would be or using #[repr(packed)].
Safety
If T: AsBytes, then unsafe code may assume that it is sound to treat any
instance of the type as an immutable [u8] of length size_of::<T>(). If a
type is marked as AsBytes which violates this contract, it may cause
undefined behavior.
If a type has the following properties, then it is safe to implement
AsBytes for that type
- If the type is a struct:
- It must have a defined representation (
repr(C),repr(transparent), orrepr(packed)). - All of its fields must be
AsBytes - Its layout must have no padding. This is always true for
repr(transparent)andrepr(packed). Forrepr(C), see the layout algorithm described in the Rust Reference.
- It must have a defined representation (
- If the type is an enum:
- It must be a C-like enum (meaning that all variants have no fields)
- It must have a defined representation (
reprsC,u8,u16,u32,u64,usize,i8,i16,i32,i64, orisize).
Provided methods
fn as_bytes(&self) -> &[u8]
Get the bytes of this value.
as_bytes provides access to the bytes of this value as an immutable
byte slice.
fn as_bytes_mut(&mut self) -> &mut [u8] where
Self: FromBytes,
Self: FromBytes,
Get the bytes of this value mutably.
as_bytes_mut provides access to the bytes of this value as a mutable
byte slice.
Implementations on Foreign Types
impl AsBytes for Key[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Key: Sized, [src]
Key: Sized,
impl AsBytes for NetworkKey[src]
impl AsBytes for Signature[src]
impl AsBytes for EphPublicKey[src]
impl AsBytes for PublicKey[src]
impl AsBytes for SharedSecret[src]
impl AsBytes for Hash[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Hash: Sized, [src]
Hash: Sized,
impl AsBytes for NetworkAuth[src]
impl AsBytes for Nonce[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Nonce: Sized, [src]
Nonce: Sized,
impl AsBytes for Hmac[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Hmac: Sized, [src]
Hmac: Sized,
impl AsBytes for SecretKey[src]
impl AsBytes for i64
fn only_derive_is_allowed_to_implement_this_trait() where
i64: Sized,
i64: Sized,
impl<T> AsBytes for [T; 11] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 11]: Sized,
[T; 11]: Sized,
impl AsBytes for i8
fn only_derive_is_allowed_to_implement_this_trait() where
i8: Sized,
i8: Sized,
impl<T> AsBytes for [T; 24] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 24]: Sized,
[T; 24]: Sized,
impl<T> AsBytes for [T; 128] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 128]: Sized,
[T; 128]: Sized,
impl<T> AsBytes for [T; 49] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 49]: Sized,
[T; 49]: Sized,
impl<T> AsBytes for [T; 55] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 55]: Sized,
[T; 55]: Sized,
impl<T> AsBytes for [T; 17] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 17]: Sized,
[T; 17]: Sized,
impl<T> AsBytes for [T; 47] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 47]: Sized,
[T; 47]: Sized,
impl<T> AsBytes for [T; 32] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 32]: Sized,
[T; 32]: Sized,
impl<T> AsBytes for [T; 2048] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 2048]: Sized,
[T; 2048]: Sized,
impl<T> AsBytes for [T; 64] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 64]: Sized,
[T; 64]: Sized,
impl<T> AsBytes for [T; 5] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 5]: Sized,
[T; 5]: Sized,
impl<T> AsBytes for [T; 42] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 42]: Sized,
[T; 42]: Sized,
impl<T> AsBytes for [T; 38] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 38]: Sized,
[T; 38]: Sized,
impl AsBytes for f32
fn only_derive_is_allowed_to_implement_this_trait() where
f32: Sized,
f32: Sized,
impl<T> AsBytes for [T; 3] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 3]: Sized,
[T; 3]: Sized,
impl<T> AsBytes for [T; 26] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 26]: Sized,
[T; 26]: Sized,
impl AsBytes for isize
fn only_derive_is_allowed_to_implement_this_trait() where
isize: Sized,
isize: Sized,
impl<T> AsBytes for [T; 512] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 512]: Sized,
[T; 512]: Sized,
impl<T> AsBytes for [T; 27] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 27]: Sized,
[T; 27]: Sized,
impl<T> AsBytes for [T; 52] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 52]: Sized,
[T; 52]: Sized,
impl<T> AsBytes for [T; 62] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 62]: Sized,
[T; 62]: Sized,
impl<T> AsBytes for [T; 22] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 22]: Sized,
[T; 22]: Sized,
impl<T> AsBytes for [T; 40] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 40]: Sized,
[T; 40]: Sized,
impl AsBytes for bool
fn only_derive_is_allowed_to_implement_this_trait() where
bool: Sized,
bool: Sized,
impl<T> AsBytes for [T; 7] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 7]: Sized,
[T; 7]: Sized,
impl<T> AsBytes for [T; 0] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 0]: Sized,
[T; 0]: Sized,
impl<T> AsBytes for [T; 37] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 37]: Sized,
[T; 37]: Sized,
impl<T> AsBytes for [T; 58] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 58]: Sized,
[T; 58]: Sized,
impl<T> AsBytes for [T; 15] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 15]: Sized,
[T; 15]: Sized,
impl<T> AsBytes for [T; 59] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 59]: Sized,
[T; 59]: Sized,
impl<T> AsBytes for [T; 29] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 29]: Sized,
[T; 29]: Sized,
impl<O> AsBytes for I64<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
I64<O>: Sized,
I64<O>: Sized,
impl AsBytes for i16
fn only_derive_is_allowed_to_implement_this_trait() where
i16: Sized,
i16: Sized,
impl<T> AsBytes for [T; 25] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 25]: Sized,
[T; 25]: Sized,
impl<T> AsBytes for [T; 57] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 57]: Sized,
[T; 57]: Sized,
impl<T> AsBytes for [T; 28] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 28]: Sized,
[T; 28]: Sized,
impl<T> AsBytes for [T; 53] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 53]: Sized,
[T; 53]: Sized,
impl<T> AsBytes for [T; 60] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 60]: Sized,
[T; 60]: Sized,
impl AsBytes for u16
fn only_derive_is_allowed_to_implement_this_trait() where
u16: Sized,
u16: Sized,
impl<T> AsBytes for [T; 255] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 255]: Sized,
[T; 255]: Sized,
impl<T> AsBytes for [T; 35] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 35]: Sized,
[T; 35]: Sized,
impl AsBytes for i128
fn only_derive_is_allowed_to_implement_this_trait() where
i128: Sized,
i128: Sized,
impl<T> AsBytes for [T; 4] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 4]: Sized,
[T; 4]: Sized,
impl<T> AsBytes for [T; 16384] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 16384]: Sized,
[T; 16384]: Sized,
impl<T> AsBytes for [T; 39] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 39]: Sized,
[T; 39]: Sized,
impl AsBytes for u32
fn only_derive_is_allowed_to_implement_this_trait() where
u32: Sized,
u32: Sized,
impl<T> AsBytes for [T; 256] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 256]: Sized,
[T; 256]: Sized,
impl<T> AsBytes for [T; 6] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 6]: Sized,
[T; 6]: Sized,
impl<T> AsBytes for [T; 9] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 9]: Sized,
[T; 9]: Sized,
impl<T> AsBytes for [T; 1024] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 1024]: Sized,
[T; 1024]: Sized,
impl<T> AsBytes for [T; 16] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 16]: Sized,
[T; 16]: Sized,
impl<T> AsBytes for [T; 19] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 19]: Sized,
[T; 19]: Sized,
impl<T> AsBytes for [T; 54] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 54]: Sized,
[T; 54]: Sized,
impl AsBytes for f64
fn only_derive_is_allowed_to_implement_this_trait() where
f64: Sized,
f64: Sized,
impl AsBytes for u8
fn only_derive_is_allowed_to_implement_this_trait() where
u8: Sized,
u8: Sized,
impl<T> AsBytes for [T; 33] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 33]: Sized,
[T; 33]: Sized,
impl<T> AsBytes for [T; 48] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 48]: Sized,
[T; 48]: Sized,
impl<T> AsBytes for [T; 1] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 1]: Sized,
[T; 1]: Sized,
impl<T> AsBytes for [T; 45] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 45]: Sized,
[T; 45]: Sized,
impl<T> AsBytes for [T; 12] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 12]: Sized,
[T; 12]: Sized,
impl<T> AsBytes for [T] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T]: Sized,
[T]: Sized,
impl<T> AsBytes for [T; 4096] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 4096]: Sized,
[T; 4096]: Sized,
impl<T> AsBytes for [T; 8] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 8]: Sized,
[T; 8]: Sized,
impl<T> AsBytes for [T; 50] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 50]: Sized,
[T; 50]: Sized,
impl<T> AsBytes for [T; 23] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 23]: Sized,
[T; 23]: Sized,
impl<O> AsBytes for I32<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
I32<O>: Sized,
I32<O>: Sized,
impl<T> AsBytes for [T; 30] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 30]: Sized,
[T; 30]: Sized,
impl<O> AsBytes for I16<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
I16<O>: Sized,
I16<O>: Sized,
impl<O> AsBytes for U16<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
U16<O>: Sized,
U16<O>: Sized,
impl<T> AsBytes for [T; 65536] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 65536]: Sized,
[T; 65536]: Sized,
impl<T> AsBytes for [T; 18] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 18]: Sized,
[T; 18]: Sized,
impl<O> AsBytes for I128<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
I128<O>: Sized,
I128<O>: Sized,
impl<T> AsBytes for [T; 98] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 98]: Sized,
[T; 98]: Sized,
impl<T> AsBytes for [T; 2] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 2]: Sized,
[T; 2]: Sized,
impl AsBytes for u128
fn only_derive_is_allowed_to_implement_this_trait() where
u128: Sized,
u128: Sized,
impl<T> AsBytes for [T; 61] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 61]: Sized,
[T; 61]: Sized,
impl<T> AsBytes for [T; 126] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 126]: Sized,
[T; 126]: Sized,
impl<O> AsBytes for U64<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
U64<O>: Sized,
U64<O>: Sized,
impl<T> AsBytes for [T; 14] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 14]: Sized,
[T; 14]: Sized,
impl<T> AsBytes for [T; 46] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 46]: Sized,
[T; 46]: Sized,
impl<T> AsBytes for [T; 32768] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 32768]: Sized,
[T; 32768]: Sized,
impl<T> AsBytes for [T; 34] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 34]: Sized,
[T; 34]: Sized,
impl<T> AsBytes for PhantomData<T>
fn only_derive_is_allowed_to_implement_this_trait() where
PhantomData<T>: Sized,
PhantomData<T>: Sized,
impl<O> AsBytes for U32<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
U32<O>: Sized,
U32<O>: Sized,
impl<T> AsBytes for [T; 56] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 56]: Sized,
[T; 56]: Sized,
impl AsBytes for usize
fn only_derive_is_allowed_to_implement_this_trait() where
usize: Sized,
usize: Sized,
impl<T> AsBytes for [T; 13] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 13]: Sized,
[T; 13]: Sized,
impl<T> AsBytes for [T; 10] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 10]: Sized,
[T; 10]: Sized,
impl<T> AsBytes for [T; 63] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 63]: Sized,
[T; 63]: Sized,
impl<T> AsBytes for [T; 51] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 51]: Sized,
[T; 51]: Sized,
impl<T> AsBytes for [T; 36] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 36]: Sized,
[T; 36]: Sized,
impl AsBytes for i32
fn only_derive_is_allowed_to_implement_this_trait() where
i32: Sized,
i32: Sized,
impl<T> AsBytes for [T; 20] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 20]: Sized,
[T; 20]: Sized,
impl<T> AsBytes for [T; 41] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 41]: Sized,
[T; 41]: Sized,
impl<T> AsBytes for [T; 8192] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 8192]: Sized,
[T; 8192]: Sized,
impl<O> AsBytes for U128<O> where
O: ByteOrder,
O: ByteOrder,
fn only_derive_is_allowed_to_implement_this_trait() where
U128<O>: Sized,
U128<O>: Sized,
impl<T> AsBytes for [T; 44] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 44]: Sized,
[T; 44]: Sized,
impl AsBytes for u64
fn only_derive_is_allowed_to_implement_this_trait() where
u64: Sized,
u64: Sized,
impl<T> AsBytes for [T; 43] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 43]: Sized,
[T; 43]: Sized,
impl<T> AsBytes for [T; 236] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 236]: Sized,
[T; 236]: Sized,
impl<T> AsBytes for [T; 21] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 21]: Sized,
[T; 21]: Sized,
impl<T> AsBytes for [T; 31] where
T: AsBytes,
T: AsBytes,
fn only_derive_is_allowed_to_implement_this_trait() where
[T; 31]: Sized,
[T; 31]: Sized,
impl AsBytes for ()
fn only_derive_is_allowed_to_implement_this_trait() where
(): Sized,
(): Sized,
Implementors
impl AsBytes for Keypair[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Keypair: Sized, [src]
Keypair: Sized,