Frame.rebuild

Reinitializes the Frame object from a supplied buffer.

This function will first call $(FREF Frame.close) to release the resources associated with the message frame, and then it will initialize it anew, exactly as if it were constructed with Frame(data) or Frame(data, free, hint).

Some care must be taken when using these functions. Please read the $(LINK2 #Frame.opCall_data,Frame(ubyte[])) documentation.

  1. void rebuild()
  2. void rebuild(size_t size)
  3. void rebuild(ubyte[] data)
  4. void rebuild(ubyte[] data, FreeData free, void* hint)
    struct Frame
    @safe @system
    void
    rebuild
    (
    ubyte[] data
    ,,
    void* hint = null
    )

Throws

ZmqException if $(ZMQ) reports an error.

Corresponds to

$(ZMQREF zmq_msg_close()) followed by $(ZMQREF zmq_msg_init_data()).

Examples

// Garbage-collected memory
auto msg = Frame(256);
assert (msg.size == 256);
auto buf = new ubyte[123];
msg.rebuild(buf);
assert(msg.size == buf.length);
assert(msg.data.ptr == buf.ptr);
// Manually managed memory
import core.stdc.stdlib: malloc, free;
static extern(C) void myFree(void* data, void* hint) nothrow { free(data); }

auto msg = Frame(256);
assert (msg.size == 256);
auto buf = (cast(ubyte*) malloc(10))[0 .. 10];
msg.rebuild(buf, &myFree);
assert(msg.size == buf.length);
assert(msg.data.ptr == buf.ptr);

Meta