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§

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

Structs§

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

Enums§

  • An enum representing any ruby value.

Traits§

  • Provides access to array elements.
  • A structure that can be deserialized from ruby marshal format.
  • A structure that can deserialize data from ruby marshal format.
  • Provides access to hash elements.
  • Provides a visitor with access to an instance.
  • Provides access to instance variables.
  • A structure that can be serialized into ruby marshal data.
  • A structure that can serialize an array.
  • A structure that can serialize a hash.
  • A structure that can serialize instance variables of an object.
  • A structure that can serialize data into ruby marshal format.
  • This trait represents a visitor that walks through a deserializer.
  • This trait represents a visitor that walks through a deserializer.
  • This trait represents a visitor that walks through a deserializer.

Functions§

Type Aliases§

  • Type alias around a result.
  • Shorthand type alias for a ruby array.
  • 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.
  • Shorthand type alias for a ruby hash.
  • Type alias around a result.

Derive Macros§