tagion_document_get_u8_array

Get binary from a document

extern (C)
int
tagion_document_get_u8_array
(,
uint8_t** buf
,
size_t* buf_len
)

Parameters

element Document.Element*

element to get

buf uint8_t**

pointer to read buffer

buf_len size_t*

pointer to buffer length

Return Value

Type: int

ErrorCode

Examples

auto h = new HiBON;
string key_binary = "binary";
immutable(ubyte[]) binary_data = [0,1,0,1];
h[key_binary] = binary_data;
const doc = Document(h);

Document.Element elm_binary;
int rt = tagion_document_element_by_key(&doc.data[0], doc.data.length, &key_binary[0], key_binary.length, &elm_binary);
assert(rt == ErrorCode.none, "Get document element binary returned error");

uint8_t* buf;
size_t buf_len;
rt = tagion_document_get_u8_array(&elm_binary, &buf, &buf_len);
assert(rt == ErrorCode.none);

auto read_data = cast(immutable) buf[0..buf_len];

assert(binary_data == read_data);