pymap.fetch

class pymap.fetch.LoadedMessageProvider(*args, **kwargs)[source]

Generic protocol that provides access to a message’s loaded contents when they are available.

abstract property loaded_msg: LoadedMessageInterface | None

The loaded message, if available.

class pymap.fetch.DynamicFetchValue(attribute, *, message, selected)[source]

Base class for fetch values that are dynamically read from a message.

Parameters:
abstract get_value()[source]

Computes the value of the fetch attribute for the message.

Return type:

bytes | SupportsBytes

class pymap.fetch.DynamicLoadedFetchValue(attribute, *, message, get_loaded)[source]

Base class for fetch values that are dynamically read from a message and require loading its contents.

Parameters:
abstract get_value(loaded_msg)[source]

Computes the value of the fetch attribute for the message.

Parameters:

loaded_msg (LoadedMessageInterface) – The loaded message object.

Return type:

bytes | SupportsBytes

class pymap.fetch.MessageAttributes(message, selected, attributes)[source]

Defines the logic for how fetch attributes are resolved on a message to produce a fetch value.

Parameters:
placeholder: ClassVar[bytes] = b'...'

Placeholder value for fetch values requiring loaded message contents.

load_hook()[source]

An async context manager that loads the message content on entry, and releases it on exit. Fetch values that require loaded message content will write placeholder if written outside of this context manager, for console or log output.

Return type:

AsyncIterator[None]