4.8.5. Network Structs#

class caterpillar.fields.MACAddress(sep: str | None = None, encoding: str | None = None)[source]#

A transformer for encoding and decoding MAC addresses.

Parameters:

sep (Optional[str]) – The separator to use in the MAC address representation.

encode(obj: str | bytes, context: _ContextLike) bytes[source]#

Encode a MAC address.

Parameters:
  • obj (Union[str, bytes]) – The MAC address to encode.

  • context (_ContextLike) – The context for encoding.

Returns:

The encoded value.

decode(parsed: bytes, context: _ContextLike) bytes[source]#

Decode an encoded MAC address.

Parameters:
  • parsed (bytes) – The parsed bytes representing the MAC address.

  • context (_ContextLike) – The context for decoding.

Returns:

The decoded MAC address.

fields.MAC = <MACAddress>#

shortcut for default MAC address format

caterpillar.fields.IPv4Address = <IPv4Address>[source]#

A transformer for encoding and decoding IPv4 addresses.

caterpillar.fields.IPv6Address = <IPv6Address>[source]#

A transformer for encoding and decoding IPv6 addresses.