Trait redb::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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Value for &str

§

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

§

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]

§

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

§

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

§

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

§

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

§

type SelfType<'a> = char

§

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

§

type SelfType<'a> = f32

§

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

§

type SelfType<'a> = f64

§

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

§

type SelfType<'a> = i8

§

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

§

type SelfType<'a> = i16

§

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

§

type SelfType<'a> = i32

§

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

§

type SelfType<'a> = i64

§

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

§

type SelfType<'a> = i128

§

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

§

type SelfType<'a> = u8

§

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

§

type SelfType<'a> = u16

§

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

§

type SelfType<'a> = u32

§

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

§

type SelfType<'a> = u64

§

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

§

type SelfType<'a> = u128

§

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 ()

§

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

§

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

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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)

§

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

§

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>

§

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

§

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>

§

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

§

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]

§

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

§

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]

§

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

§

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§