# Message

class dbus_fast.Message(destination: str | None = None, path: str | None = None, interface: str | None = None, member: str | None = None, message_type: ~dbus_fast.constants.MessageType = MessageType.METHOD_CALL, flags: ~dbus_fast.constants.MessageFlag | int = <MessageFlag.NONE: 0>, error_name: str | ~dbus_fast.constants.ErrorType | None = None, reply_serial: int | None = None, sender: str | None = None, unix_fds: list[int] = [], signature: ~dbus_fast.signature.SignatureTree | str | None = None, body: list[~typing.Any] = [], serial: int | None = None, validate: bool = True)

  A class for sending and receiving messages through the `MessageBus` with the low-level api.

  A `Message` can be constructed by the user to send over the message bus. When messages are received, such as from method calls or signal emissions, they will use this class as well.

  Variables:

    - destination (str) – The address of the client for which this message is intended.

    - path (str) – The intended object path exported on the destination bus.

    - interface (str) – The intended interface on the object path.

    - member (str) – The intended member on the interface.

    - message_type (`MessageType`) – The type of this message. A method call, signal, method return, or error.

    - flags (`MessageFlag`) – Flags that affect the behavior of this message.

    - error_name (str) – If this message is an error, the name of this error. Must be a valid interface name.

    - reply_serial (int) – If this is a return type, the serial this message is in reply to.

    - sender (str) – The address of the sender of this message. Will be a unique name.

    - unix_fds (list(int)) – A list of unix fds that were sent in the header of this message.

    - signature (str) – The signature of the body of this message.

    - signature_tree (`SignatureTree`) – The signature parsed as a signature tree.

    - body (list(Any)) – The body of this message. Must match the signature.

    - serial (int) – The serial of the message. Will be automatically set during message sending if not present. Use the `new_serial()` method of the bus to generate a serial.

  Raises:

    - `InvalidMessageError` - If the message is malformed or missing fields for the message type.

    - `InvalidSignatureError` - If the given signature is not valid.

    - `InvalidObjectPathError` - If `path` is not a valid object path.

    - `InvalidBusNameError` - If `destination` is not a valid bus name.

    - `InvalidMemberNameError` - If `member` is not a valid member name.

    - `InvalidInterfaceNameError` - If `error_name` or `interface` is not a valid interface name.

  body
  destination
  error_name
  flags
  interface
  member
  message_type
  static new_error(msg: Message, error_name: str | ErrorType, error_text: str) → Message

    A convenience constructor to create an error message in reply to the given message.

    Parameters:

      - msg (`Message`) – The message this error is in reply to.

      - error_name (str) – The name of this error. Must be a valid interface name.

      - error_text – Human-readable text for the error.

    Returns:

      The error message.

    Return type:

      `Message`

    Raises:

      - `InvalidInterfaceNameError` - If the error_name is not a valid interface name.

  static new_method_return(msg: Message, signature: str = '', body: list[Any] = [], unix_fds: list[int] = []) → Message

    A convenience constructor to create a method return to the given method call message.

    Parameters:

      - msg (`Message`) – The method call message this is a reply to.

      - signature (str) – The signature for the message body.

      - body (list(int)) – The body of this message. Must match the signature.

      - unix_fds – List integer file descriptors to send with this message.

    Returns:

      The method return message

    Return type:

      `Message`

    Raises:

      - `InvalidSignatureError` - If the signature is not a valid signature.

  static new_signal(path: str, interface: str, member: str, signature: str = '', body: list[Any] | None = None, unix_fds: list[int] | None = None) → Message

    A convenience constructor to create a new signal message.

    Parameters:

      - path (str) – The path of this signal.

      - interface (str) – The interface of this signal.

      - member (str) – The member name of this signal.

      - signature (str) – The signature of the signal body.

      - body (list(int)) – The body of this signal message.

      - unix_fds – List integer file descriptors to send with this message.

    Returns:

      The signal message.

    Return type:

      `Message`

    Raises:

      - `InvalidSignatureError` - If the signature is not a valid signature.

      - `InvalidObjectPathError` - If `path` is not a valid object path.

      - `InvalidInterfaceNameError` - If `interface` is not a valid interface name.

      - `InvalidMemberNameError` - If `member` is not a valid member name.

  path
  reply_serial
  sender
  serial
  signature
  signature_tree
  unix_fds