# DO NOT EDIT!
# This code was auto generated by the `protoc-gen-pokete-resources-python` plugin,
# part of the pokete project, by <lxgr@protonmail.com>
from typing import TypedDict


class TrackInfoDict(TypedDict):
    name: str
    hash: bytes


class TrackInfo:
    def __init__(self, name: str, hash: bytes):
        self.name: str = name
        self.hash: bytes = hash

    @classmethod
    def from_dict(cls, _d: TrackInfoDict | None) -> "TrackInfo | None":
        if _d is None:
            return None
        return cls(
            name=_d["name"],
            hash=_d["hash"],
        )

    @staticmethod
    def validate(_d: TrackInfoDict) -> bool:
        return all(
            [
                "name" in _d and type(_d["name"]) is str,
                "hash" in _d and type(_d["hash"]) is bytes,
            ]
        )

    def to_dict(self) -> TrackInfoDict:
        ret: TrackInfoDict = {}

        ret["name"] = self.name
        ret["hash"] = self.hash

        return ret


class TrackDict(TypedDict):
    info: "TrackInfoDict"
    content: bytes


class Track:
    def __init__(self, info: "TrackInfo", content: bytes):
        self.info: "TrackInfo" = info
        self.content: bytes = content

    @classmethod
    def from_dict(cls, _d: TrackDict | None) -> "Track | None":
        if _d is None:
            return None
        return cls(
            info=TrackInfo.from_dict(_d["info"]),
            content=_d["content"],
        )

    @staticmethod
    def validate(_d: TrackDict) -> bool:
        return all(
            [
                "info" in _d and TrackInfo.validate(_d["info"]),
                "content" in _d and type(_d["content"]) is bytes,
            ]
        )

    def to_dict(self) -> TrackDict:
        ret: TrackDict = {}

        ret["info"] = TrackInfo.to_dict(self.info)
        ret["content"] = self.content

        return ret
