struct Athena::Serializer::Serializer
- Athena::Serializer::Serializer
- Struct
- Value
- Object
Overview
Default implementation of ASR::SerializerInterface
.
Provides the main API used to (de)serialize objects.
Custom formats can be implemented by creating the required visitors for that type, then overriding #get_deserialization_visitor_class
and #get_serialization_visitor_class
.
# Redefine the visitor class getters in order to first check for custom formats.
# This assumes these visitor types are defined, with the proper logic to handle
# the (de)serialization process.
struct Athena::Serializer::Serializer
protected def get_deserialization_visitor_class(format : ASR::Format | String)
return MessagePackDeserializationVisitor if format == "message_pack"
previous_def
end
protected def get_serialization_visitor_class(format : ASR::Format | String)
return MessagePackSerializationVisitor if format == "message_pack"
previous_def
end
end
Included Modules
Defined in:
serializer.crConstructors
Instance Method Summary
-
#deserialize(type : _, data : String | IO, format : ASR::Format | String, context : ASR::DeserializationContext = ASR::DeserializationContext.new)
:inherit:
-
#serialize(data : _, format : ASR::Format | String, io : IO, context : ASR::SerializationContext = ASR::SerializationContext.new, **named_args) : Nil
Serializes the provided data into format writing it to the provided io, optionally with the provided context.=
-
#serialize(data : _, format : ASR::Format | String, context : ASR::SerializationContext = ASR::SerializationContext.new, **named_args) : String
Serializes the provided data into format, optionally with the provided context.
Instance methods inherited from module Athena::Serializer::SerializerInterface
deserialize(type : ASR::Model.class, data : String | IO, format : ASR::Format | String, context : ASR::DeserializationContext = ASR::DeserializationContext.new)
deserialize,
serialize(data : _, format : ASR::Format | String, io : IO, context : ASR::SerializationContext = ASR::SerializationContext.new, **named_args) : Nilserialize(data : _, format : ASR::Format | String, context : ASR::SerializationContext = ASR::SerializationContext.new, **named_args) : String serialize
Constructor Detail
Instance Method Detail
def deserialize(type : _, data : String | IO, format : ASR::Format | String, context : ASR::DeserializationContext = ASR::DeserializationContext.new)
#
:inherit:
def serialize(data : _, format : ASR::Format | String, io : IO, context : ASR::SerializationContext = ASR::SerializationContext.new, **named_args) : Nil
#
Serializes the provided data into format writing it to the provided io, optionally with the provided context.=
def serialize(data : _, format : ASR::Format | String, context : ASR::SerializationContext = ASR::SerializationContext.new, **named_args) : String
#
Serializes the provided data into format, optionally with the provided context.