redb

Trait Value

Source
pub trait Value: Debug {
    type SelfType<'a>: Debug + 'a
       where Self: 'a;
    type AsBytes<'a>: AsRef<[u8]> + 'a
       where Self: 'a;

    // Required methods
    fn fixed_width() -> Option<usize>;
    fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
       where Self: 'a;
    fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Self::AsBytes<'a>
       where Self: 'a + 'b;
    fn type_name() -> TypeName;
}

Required Associated Types§

Source

type SelfType<'a>: Debug + 'a where Self: 'a

SelfType<’a> must be the same type as Self with all lifetimes replaced with ’a

Source

type AsBytes<'a>: AsRef<[u8]> + 'a where Self: 'a

Required Methods§

Source

fn fixed_width() -> Option<usize>

Width of a fixed type, or None for variable width

Source

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Deserializes data Implementations may return a view over data, or an owned type

Source

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Self::AsBytes<'a>
where Self: 'a + 'b,

Serialize the value to a slice

Source

fn type_name() -> TypeName

Globally unique identifier for this type

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Value for &str

Source§

type SelfType<'a> = &'a str where Self: 'a

Source§

type AsBytes<'a> = &'a str where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> &'a str
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> &'a str
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for &[u8]

Source§

type SelfType<'a> = &'a [u8] where Self: 'a

Source§

type AsBytes<'a> = &'a [u8] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> &'a [u8]
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> &'a [u8]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for bool

Source§

type SelfType<'a> = bool where Self: 'a

Source§

type AsBytes<'a> = &'a [u8] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> bool
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> &'a [u8]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for char

Source§

type SelfType<'a> = char

Source§

type AsBytes<'a> = [u8; 3] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> char
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 3]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for f32

Source§

type SelfType<'a> = f32

Source§

type AsBytes<'a> = [u8; 4] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> f32
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 4]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for f64

Source§

type SelfType<'a> = f64

Source§

type AsBytes<'a> = [u8; 8] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> f64
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 8]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for i8

Source§

type SelfType<'a> = i8

Source§

type AsBytes<'a> = [u8; 1] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> i8
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 1]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for i16

Source§

type SelfType<'a> = i16

Source§

type AsBytes<'a> = [u8; 2] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> i16
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 2]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for i32

Source§

type SelfType<'a> = i32

Source§

type AsBytes<'a> = [u8; 4] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> i32
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 4]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for i64

Source§

type SelfType<'a> = i64

Source§

type AsBytes<'a> = [u8; 8] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> i64
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 8]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for i128

Source§

type SelfType<'a> = i128

Source§

type AsBytes<'a> = [u8; 16] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> i128
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 16]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for u8

Source§

type SelfType<'a> = u8

Source§

type AsBytes<'a> = [u8; 1] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> u8
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 1]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for u16

Source§

type SelfType<'a> = u16

Source§

type AsBytes<'a> = [u8; 2] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> u16
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 2]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for u32

Source§

type SelfType<'a> = u32

Source§

type AsBytes<'a> = [u8; 4] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> u32
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 4]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for u64

Source§

type SelfType<'a> = u64

Source§

type AsBytes<'a> = [u8; 8] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> u64
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 8]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for u128

Source§

type SelfType<'a> = u128

Source§

type AsBytes<'a> = [u8; 16] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> u128
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> [u8; 16]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for ()

Source§

type SelfType<'a> = () where Self: 'a

Source§

type AsBytes<'a> = &'a [u8] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(_data: &'a [u8])
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(_: &'a Self::SelfType<'b>) -> &'a [u8]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl Value for String

Source§

type SelfType<'a> = String where Self: 'a

Source§

type AsBytes<'a> = &'a str where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> String
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> &'a str
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value> Value for (T0, T1)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value> Value for (T0, T1, T2)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value> Value for (T0, T1, T2, T3)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value> Value for (T0, T1, T2, T3, T4)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value> Value for (T0, T1, T2, T3, T4, T5)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value, T6: Value> Value for (T0, T1, T2, T3, T4, T5, T6)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>, <T6 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value, T6: Value, T7: Value> Value for (T0, T1, T2, T3, T4, T5, T6, T7)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>, <T6 as Value>::SelfType<'a>, <T7 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value, T6: Value, T7: Value, T8: Value> Value for (T0, T1, T2, T3, T4, T5, T6, T7, T8)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>, <T6 as Value>::SelfType<'a>, <T7 as Value>::SelfType<'a>, <T8 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value, T6: Value, T7: Value, T8: Value, T9: Value> Value for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>, <T6 as Value>::SelfType<'a>, <T7 as Value>::SelfType<'a>, <T8 as Value>::SelfType<'a>, <T9 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value, T6: Value, T7: Value, T8: Value, T9: Value, T10: Value> Value for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>, <T6 as Value>::SelfType<'a>, <T7 as Value>::SelfType<'a>, <T8 as Value>::SelfType<'a>, <T9 as Value>::SelfType<'a>, <T10 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T0: Value, T1: Value, T2: Value, T3: Value, T4: Value, T5: Value, T6: Value, T7: Value, T8: Value, T9: Value, T10: Value, T11: Value> Value for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

type SelfType<'a> = (<T0 as Value>::SelfType<'a>, <T1 as Value>::SelfType<'a>, <T2 as Value>::SelfType<'a>, <T3 as Value>::SelfType<'a>, <T4 as Value>::SelfType<'a>, <T5 as Value>::SelfType<'a>, <T6 as Value>::SelfType<'a>, <T7 as Value>::SelfType<'a>, <T8 as Value>::SelfType<'a>, <T9 as Value>::SelfType<'a>, <T10 as Value>::SelfType<'a>, <T11 as Value>::SelfType<'a>) where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T: Value> Value for Option<T>

Source§

type SelfType<'a> = Option<<T as Value>::SelfType<'a>> where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Option<T::SelfType<'a>>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<T: Value> Value for Vec<T>

Source§

type SelfType<'a> = Vec<<T as Value>::SelfType<'a>> where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> Vec<T::SelfType<'a>>
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Vec<T::SelfType<'b>>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<const N: usize> Value for &[u8; N]

Source§

type SelfType<'a> = &'a [u8; N] where Self: 'a

Source§

type AsBytes<'a> = &'a [u8; N] where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> &'a [u8; N]
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> &'a [u8; N]
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Source§

impl<const N: usize, T: Value> Value for [T; N]

Source§

type SelfType<'a> = [<T as Value>::SelfType<'a>; N] where Self: 'a

Source§

type AsBytes<'a> = Vec<u8> where Self: 'a

Source§

fn fixed_width() -> Option<usize>

Source§

fn from_bytes<'a>(data: &'a [u8]) -> [T::SelfType<'a>; N]
where Self: 'a,

Source§

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Vec<u8>
where Self: 'a + 'b,

Source§

fn type_name() -> TypeName

Implementors§