rainbowadn/rainbowadn/collection/trees/binary/core/binaryprotocolized.py
2022-07-10 21:14:02 +03:00

27 lines
734 B
Python

from typing import Generic, Optional, TypeVar
from .binarycreation import *
from .binarysplit import *
__all__ = ('BinaryProtocolized',)
TreeType = TypeVar('TreeType')
ActiveKeyType = TypeVar('ActiveKeyType')
MetaDataType = TypeVar('MetaDataType')
class BinaryProtocolized(
Generic[ActiveKeyType, MetaDataType, TreeType]
):
def __init__(
self,
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
tree: TreeType
):
assert isinstance(creation, BinaryCreation)
self.creation = creation
self.tree = tree
async def split(self) -> Optional[BinarySplit[ActiveKeyType, MetaDataType, TreeType]]:
return await self.creation.split(self.tree)