"""Reranking result protocol."""

from typing import Protocol, runtime_checkable


@runtime_checkable
class RerankResultProtocol(Protocol):
    """Protocol for a single reranking result.

    Example:
        >>> result = response.results[0]
        >>> print(f"Document {result.index}: score {result.score:.3f}")
        >>> if result.document:
        ...     print(f"Text: {result.document}")
    """

    @property
    def index(self) -> int:
        """Index of the document in the original input list."""
        ...

    @property
    def score(self) -> float:
        """Relevance score indicating how relevant the document is to the query.

        Higher scores indicate more relevance.
        """
        ...

    @property
    def document(self) -> str | None:
        """Optional document text (if return_documents=True)."""
        ...
