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

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§