tagion_hirpc_create_sender

Create a hirpc from a document

extern (C)
int
tagion_hirpc_create_sender
(
const char* method
,
const size_t method_len
,
const ubyte* param
,
const size_t param_len
,
ubyte** out_doc
,
size_t* out_doc_len
)

Parameters

method char*

The name of the method

method_len size_t

The length of the method string

param ubyte*

Optional the document to use as the parameter

param_len size_t

The length of the document parameter

out_doc ubyte**

The resulting hirpc as a document

out_doc_len size_t*

The length of the resulting document

Return Value

Type: int

Examples

import tagion.api.hibon;
import tagion.api.document;

ubyte* doc_param_ptr = new ubyte;
size_t doc_param_len;
{
    HiBONT* hibon = new HiBONT;
    int rc = tagion_hibon_create(hibon);
    assert(rc == 0);
    scope(exit) tagion_hibon_free(hibon);
    const char[] key = "a";
    rc = tagion_hibon_add_int32(hibon, &key[0], key.length, 7);
    assert(rc == 0);

    rc = tagion_hibon_get_document(hibon, &doc_param_ptr, &doc_param_len);
    assert(rc == 0);
}

string method = "some_method";

ubyte* result_doc_ptr = new ubyte;
size_t result_doc_len;

int rc = tagion_hirpc_create_sender(&method[0], method.length, doc_param_ptr, doc_param_len, &result_doc_ptr, &result_doc_len);
assert(rc == 0);

const doc = Document(result_doc_ptr[0 .. result_doc_len].idup);
assert(doc.isInorder);