Interface Deserializable<T>

This interface exists to define Deserializable inputs for functions that deserialize a byte buffer into a type T. It is not intended to be implemented or extended, because Typescript has no support for static methods in interfaces.

interface Deserializable<T> {
    deserialize(deserializer: Deserializer): T;
}

Type Parameters

  • T

    The type that this will deserialize into.

Methods

Methods

  • Deserializes the buffered bytes into an instance of the specified class type. This function provides an alternative syntax for deserialization, allowing users to call deserializer.deserialize(MyClass) instead of MyClass.deserialize(deserializer).

    Parameters

    • deserializer: Deserializer

      The deserializer instance with the buffered bytes.

    Returns T

    The deserialized value of class type T.

    const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));
    const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function
    // value is now an instance of MyClass
    // equivalent to `const value = MyClass.deserialize(deserializer)`