jam.types.base.null module

class jam.types.base.null.Nullable[source]

Bases: Codable, JsonSerde

Null value implementation.

A Null represents the absence of a value. It is encoded as an empty byte sequence.

Examples

>>> null = Null()
>>> encoded = null.encode()
>>> assert encoded == b""
>>> decoded, size = Null.decode_from(encoded)
>>> assert decoded == null
>>> assert size == 0
__init__()[source]

Initialize Null value.

get() None[source]

Get the null value.

Returns:

None

__repr__() str[source]

Get string representation.

__eq__(other: object) bool[source]

Compare for equality.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Nullable, int][source]

Decode null value from buffer.

Parameters:
  • buffer – Source buffer

  • offset – Starting offset

Returns:

Tuple of (decoded null value, bytes read)

to_json() None[source]

Convert to JSON representation.

classmethod from_json(data: Any) Nullable[source]

Create from JSON representation.

jam.types.base.null

Null type implementation for the JAM protocol.

Type Definitions

Null

  • Zero-sized type

  • Represents absence of value

  • No storage overhead

  • Used in optional types

Encoding Format

Null:

None -> []  # Zero bytes

Implementation Details

Memory Layout

  • Null: No storage

  • No padding or alignment

  • Zero-copy for None

Examples

Null Type

from jam.types.base.null import Null

# Create and encode
value = Null()
encoded = value.encode()  # -> []

# Decode
decoded = Null.decode(encoded)
assert decoded is None

API Reference

Classes

jam.types.base.null.Null

alias of Null

class jam.types.base.null.Nullable[source]

Bases: Codable, JsonSerde

Null value implementation.

A Null represents the absence of a value. It is encoded as an empty byte sequence.

Examples

>>> null = Null()
>>> encoded = null.encode()
>>> assert encoded == b""
>>> decoded, size = Null.decode_from(encoded)
>>> assert decoded == null
>>> assert size == 0
__init__()[source]

Initialize Null value.

get() None[source]

Get the null value.

Returns:

None

__repr__() str[source]

Get string representation.

__eq__(other: object) bool[source]

Compare for equality.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Nullable, int][source]

Decode null value from buffer.

Parameters:
  • buffer – Source buffer

  • offset – Starting offset

Returns:

Tuple of (decoded null value, bytes read)

to_json() None[source]

Convert to JSON representation.

classmethod from_json(data: Any) Nullable[source]

Create from JSON representation.

Decorators