Skip to content

bus: new interface API #60

@allisonkarlitskaya

Description

@allisonkarlitskaya

A new way of defining D-Bus interfaces:

class org_example_Interface(bus.Interface):
    # this is a D-Bus property
    power_level: int

    # this too
    @property
    def identifier(self) -> str:
        raise NotImplementedError

    @identifier.setter
    def set_identifier(self, value: str) -> None:
        raise NotImplementedError

    # a bus method
    def change(self, name: dict[str, bus.Variant]) -> list[str]:
        raise NotImplementedError

    # a signal
    def changed(self, name: str) -> bus.Signal:
        ...

The above would result in an interface called org.example.Interface with:

  • read-only property PowerLevel of type int
  • read-only property Identifier of type s
  • method Change accepting a{sv} and returning as
  • a signal Changed with a single s value

Properties would be read-only unless a property.setter was provided.

In order to export an object using the interface, you'd be expected to put it on the bus via an object which implements the interface.

class MyObject(bus.Object, org_example_Interface):
  ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions