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
_dumpmethod. - userclass: A subclass of a ruby object like
HashorArray. - 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 usesVec<u8>instead. - RbStruct
- A type equivalent to ruby’s
Struct. - SerError
- Serialize
Byte String - A helper to ensure byte slices are serialized as strings.
- Serializer
- The
alox_48serializer. - 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
_dumpfrom ruby. Its main intended use is inValue, but you can also use it withDeserialize: - Value
Serializer - Serializer whose output is a
Value.
Enums§
- Value
- An enum representing any ruby value.
Traits§
- Array
Access - Provides access to array elements.
- Deserialize
- A structure that can be deserialized from ruby marshal format.
- Deserializer
Trait - A structure that can deserialize data from ruby marshal format.
- Hash
Access - Provides access to hash elements.
- Instance
Access - Provides a visitor with access to an instance.
- Ivar
Access - Provides access to instance variables.
- Serialize
- A structure that can be serialized into ruby marshal data.
- Serialize
Array - A structure that can serialize an array.
- Serialize
Hash - A structure that can serialize a hash.
- Serialize
Ivars - A structure that can serialize instance variables of an object.
- Serializer
Trait - A structure that can serialize data into ruby marshal format.
- Visitor
- This trait represents a visitor that walks through a deserializer.
- Visitor
Instance - This trait represents a visitor that walks through a deserializer.
- Visitor
Option - 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::newandDeserialize::deserialize. - from_
value - Interpret a
Valueas an instance of typeT. - to_
bytes - Serialize the type into bytes.
- to_
value - Convert a
TintoValue.
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
Symbolto 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
Deserializefor a struct. - Serialize
- Derive
Serializefor a struct.