26 lines
666 B
Python
26 lines
666 B
Python
"""Protocols for switch backend implementations."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
|
|
class SwitchDriverProtocol(Protocol):
|
|
"""Required contract for all switch backends."""
|
|
|
|
def open(self) -> None:
|
|
"""Open hardware or mock resources."""
|
|
|
|
def close(self) -> None:
|
|
"""Close hardware or mock resources."""
|
|
|
|
def position_count(self) -> int:
|
|
"""Return total number of supported positions."""
|
|
|
|
def switch_to(self, position: int) -> None:
|
|
"""Switch to requested zero-based position."""
|
|
|
|
@property
|
|
def current_position(self) -> int:
|
|
"""Return currently active position."""
|