1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use crate::private::layout::{PointerBuilder, PointerReader};
use crate::Result;
#[derive(Copy, Clone)]
pub struct Owned(());
impl<'a> crate::traits::Owned<'a> for Owned {
type Reader = Reader<'a>;
type Builder = Builder<'a>;
}
pub type Reader<'a> = &'a [u8];
pub fn new_reader<'a>(p : *const u8, len : u32) -> Reader<'a> {
unsafe { ::std::slice::from_raw_parts(p, len as usize) }
}
impl <'a> crate::traits::FromPointerReader<'a> for Reader<'a> {
fn get_from_pointer(reader: &PointerReader<'a>, default: Option<&'a [crate::Word]>) -> Result<Reader<'a>> {
reader.get_data(default)
}
}
pub type Builder<'a> = &'a mut [u8];
pub fn new_builder<'a>(p : *mut u8, len : u32) -> Builder<'a> {
unsafe { ::std::slice::from_raw_parts_mut(p, len as usize) }
}
impl <'a> crate::traits::FromPointerBuilder<'a> for Builder<'a> {
fn init_pointer(builder : PointerBuilder<'a>, size : u32) -> Builder<'a> {
builder.init_data(size)
}
fn get_from_pointer(builder :PointerBuilder<'a>, default: Option<&'a [crate::Word]>) -> Result<Builder<'a>> {
builder.get_data(default)
}
}
impl <'a> crate::traits::SetPointerBuilder<Builder<'a>> for Reader<'a> {
fn set_pointer_builder<'b>(pointer: PointerBuilder<'b>,
value: Reader<'a>,
_canonicalize: bool) -> Result<()> {
pointer.set_data(value);
Ok(())
}
}