"""Shared type definitions for gRPC mixins.

Provides Protocol-based abstractions to avoid generic type parameter issues
with grpc.aio.ServicerContext while keeping call sites easy to type.
"""

from __future__ import annotations

from typing import Protocol

import grpc


class GrpcContext(Protocol):
    """Minimal gRPC context interface used by service mixins."""

    async def abort(self, code: grpc.StatusCode, details: str) -> None:
        """Abort the RPC with given status code and details."""
        ...


class GrpcStatusContext(GrpcContext, Protocol):
    """gRPC context that supports setting status codes/details."""

    def set_code(self, code: grpc.StatusCode) -> None:
        """Set the response status code."""
        ...

    def set_details(self, details: str) -> None:
        """Set the response status details."""
        ...


__all__ = ["GrpcContext", "GrpcStatusContext"]
