module Cannon
Overview
The cannon: Really fast data de-/serialisation
Defined in:
cannon.crcannon/auto.cr
cannon/rpc.cr
cannon/rpc/connection.cr
cannon/rpc/generic_service.cr
cannon/rpc/local_connection.cr
cannon/rpc/macro.cr
cannon/rpc/manager.cr
cannon/rpc/protocol.cr
cannon/rpc/remote_service.cr
cannon/rpc/service.cr
cannon/rpc/singleton_service.cr
cannon/rpc/tcp_acceptor.cr
cannon/rpc/tcp_connection.cr
cannon/serialisation.cr
cannon/version.cr
Constant Summary
-
VERSION =
"0.2.1"
Class Method Summary
-
.encode(io, value)
Serializes value into io.
-
.simple?(*tuple)
Helper method to check if all data types in tuple are "simple".
Macro Summary
-
decode(io, type)
Deserializes type from io, returning the result.
-
fast_decode(io, type)
Helper macro to read a type from io as-is.
-
fast_encode(io, value)
Helper macro to write value into io as-is.
Class Method Detail
Serializes value into io. Returns the io.
Always use this method (And Cannon.decode
) over the instance methods.
The Cannon
methods will always use the fastest-path available, gradually
falling back to slower implementations. This mechanism does not incur any
run-time penality.
To add support for your own data structures, implement:
#to_cannon_io(io)
to write self into io.from_cannon_io(io)
to construct an instance out of io
Make sure to use Cannon.encode
in your #to_cannon_io
method, and
Cannon.decode
in your .from_cannon_io
method, for optimal speed.
You can automate this by including Cannon::Auto
into your structure.
Helper method to check if all data types in tuple are "simple". A simple
data type can be serialized by essentially pointer-casting it to Bytes
and
then blasting it into IO#write
.
Macro Detail
Helper macro to write value into io as-is.
value must be a variable and can not be a literal or self
.