from abc import ABC, abstractmethod
from typing import Generic

from ._types import AnyType


class DependencyBuilder(Generic[AnyType], ABC):
    """Abstract base class for building and destroying dependency instances."""

    @abstractmethod
    def build(self) -> AnyType:
        """Builds and returns an instance of the dependency.

        Returns:
            AnyType: The built dependency instance.
        """
        raise NotImplementedError()

    @abstractmethod
    def destroy(self, instance: AnyType) -> None:
        """Destroys the given dependency instance.

        Args:
            instance (AnyType): The dependency instance to destroy.
        """
        raise NotImplementedError()
