Blocks are serialized by writing out information on the constructor used to create the object, combining this with block state information, which constitutes values such that when passed to the constructor the original object can be re-created.
blockr_ser(x, ...)# S3 method for block
blockr_ser(x, state = NULL, ...)
# S3 method for blocks
blockr_ser(x, blocks = NULL, ...)
# S3 method for board_options
blockr_ser(x, options = NULL, ...)
# S3 method for blockr_ctor
blockr_ser(x, ...)
# S3 method for board_option
blockr_ser(x, option = NULL, ...)
# S3 method for llm_model_option
blockr_ser(x, option = NULL, ...)
# S3 method for board
blockr_ser(x, board_id = NULL, ...)
# S3 method for link
blockr_ser(x, ...)
# S3 method for links
blockr_ser(x, ...)
# S3 method for stack
blockr_ser(x, ...)
# S3 method for stacks
blockr_ser(x, ...)
blockr_deser(x, ...)
# S3 method for list
blockr_deser(x, ...)
# S3 method for block
blockr_deser(x, data, ...)
# S3 method for blocks
blockr_deser(x, data, ...)
# S3 method for board
blockr_deser(x, data, ...)
# S3 method for link
blockr_deser(x, data, ...)
# S3 method for links
blockr_deser(x, data, ...)
# S3 method for stack
blockr_deser(x, data, ...)
# S3 method for stacks
blockr_deser(x, data, ...)
# S3 method for board_options
blockr_deser(x, data, ...)
# S3 method for blockr_ctor
blockr_deser(x, data, ...)
# S3 method for board_option
blockr_deser(x, data, ...)
Serialization helper function blockr_ser() returns lists, which
for most objects contain slots object and payload, where object
contains a class vector which is used by blockr_deser() to instantiate an
empty object of that class and use S3 dispatch to identify the correct method
that, given the content in payload, can re-create the original object.
Object to (de)serialize
Generic consistency
Object state (as returned from an expr_server)
Block states (NULL defaults to values from ctor scope)
Board option values (NULL uses values provided by x)
Board option value (NULL uses values provided by x)
Board ID
List valued data (converted from JSON)
Helper functions blockr_ser() and blockr_deser() are implemented as
generics and perform most of the heavy lifting for (de-)serialization:
representing objects as easy-to-serialize (nested) lists containing mostly
strings and no objects which are hard/impossible to truthfully re-create in
new sessions (such as environments).
blk <- new_dataset_block("iris")
blockr_ser(blk)
all.equal(blk, blockr_deser(blockr_ser(blk)), check.environment = FALSE)
Run the code above in your browser using DataLab