module Crystalizer::Type

Overview

Including this type allows to define custom serialization and deserialization for a given type.

struct MyType
  include Crystalizer::Type

  def initialize(@i : Int32)
  end

  def self.deserialize(deserializer : Crystalizer::Deserializer)
    new deserializer.deserialize to: Int32
  end

  def serialize(serializer : Crystalizer::Serializer) : Nil
    serializer.serialize @i
  end
end

Defined in:

type.cr

Instance Method Summary

Instance Method Detail

abstract def serialize(serializer : Crystalizer::Serializer) : Nil #

[View source]