Crate alox_48

Crate alox_48 

Source
Expand description

alox-48 (short for aluminum oxide 48)

alox-48 supports both full serialization and deserialization of Marshal, but generally users of this library will not be using most of Marshal’s features. (Classes, Extended types, etc)

However, alox-48 does NOT support object links. Object links are marshal’s way of saving space, if an object was serialized already a “link” indicating when it was serialized is serialized instead.

class MyClass
 def initialize
   @var = 1
   @string = "hiya!"
 end
end

a = MyClass.new
Marshal.dump([a, a, a])
# The array here has 3 indices all "pointing" to the same object.
# Instead of serializing MyClass 3 times, Marshal will serialize it once and replace the other 2 occurences with object links.
# When deserializing, Marshal will preserve object links and all 3 elements in the array will point to the same object.
# In alox-48, this is not the case. Each index will be a "unique" ""object"".

This behavior could be simulated with Rc and/or Arc like thurgood, however for the sake of ergonomics (and memory cycles) alox-48 deserializes object links as copies instead. alox-48 does not serialize object links at all.

Some common terminology:

  • ivar: Instance variable. These are variables that are attached to an object.
  • instance: Not to be confused with a class instance. This is a value that is not an object with attached ivars.
  • userdata: A special type of object that is serialized by the _dump method.
  • userclass: A subclass of a ruby object like Hash or Array.
  • object: A generic ruby object. Can be anything from a string to an instance of a class.

Modules§

de
Marshal Deserialization framework and Deserializer.
path_to_error
A convenience module for getting exact details about where an error occurred.
ser
Marshal Serialization framework and Serializer.

Structs§

DeError
Deserializer
The alox-48 deserializer.
Instance
A type representing a ruby object with extra instance variables.
Object
A type equivalent to ruby’s Object.
RbString
A type equivalent to ruby’s String. ruby strings do not have to be utf8 encoded, so this type uses Vec<u8> instead.
RbStruct
A type equivalent to ruby’s Struct.
SerError
SerializeByteString
A helper to ensure byte slices are serialized as strings.
Serializer
The alox_48 serializer.
Sym
A borrowed ruby symbol.
Symbol
An owned symbol from ruby. It’s a newtype around a String, meant to preserve types during (de)serialization.
Userdata
This type represents types serialized with _dump from ruby. Its main intended use is in Value, but you can also use it with Deserialize:
ValueSerializer
Serializer whose output is a Value.

Enums§

Value
An enum representing any ruby value.

Traits§

ArrayAccess
Provides access to array elements.
Deserialize
A structure that can be deserialized from ruby marshal format.
DeserializerTrait
A structure that can deserialize data from ruby marshal format.
HashAccess
Provides access to hash elements.
InstanceAccess
Provides a visitor with access to an instance.
IvarAccess
Provides access to instance variables.
Serialize
A structure that can be serialized into ruby marshal data.
SerializeArray
A structure that can serialize an array.
SerializeHash
A structure that can serialize a hash.
SerializeIvars
A structure that can serialize instance variables of an object.
SerializerTrait
A structure that can serialize data into ruby marshal format.
Visitor
This trait represents a visitor that walks through a deserializer.
VisitorInstance
This trait represents a visitor that walks through a deserializer.
VisitorOption
This trait represents a visitor that walks through a deserializer.

Functions§

from_bytes
Deserialize data from some bytes. It’s a convenience function over Deserializer::new and Deserialize::deserialize.
from_value
Interpret a Value as an instance of type T.
to_bytes
Serialize the type into bytes.
to_value
Convert a T into Value.

Type Aliases§

DeResult
Type alias around a result.
RbArray
Shorthand type alias for a ruby array.
RbFields
A type alias used to represent fields of objects. All objects store a Symbol to represent the key for instance variable, and we do that here too.
RbHash
Shorthand type alias for a ruby hash.
SerResult
Type alias around a result.

Derive Macros§

Deserialize
Derive Deserialize for a struct.
Serialize
Derive Serialize for a struct.