Spec out send, recv and encoding_length
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Luke Murphy 2020-07-08 00:20:50 +02:00
parent ca21c317da
commit 01b3980f47
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 15 additions and 7 deletions

View File

@ -25,14 +25,22 @@ class SimpleMessageChannel:
destroyed: bool = False
error: Optional[Exception] = None
# TODO(decentral1se): need to lookup type of what is being passed in
# context: ???
# TODO(decentral1se): allow to override instead of callback interface!?
# onmissing: ???
# onmessage: ???
# TODO(decentral1se): context, onmessage, onmissing
async def send(self, channel: int, type: int, message: bytes) -> bytes:
"""Produce data that can be sent over the channel."""
header = channel << 4 or type
length = self.encoding_length(type, message) + pyvarint.encoding_length(header)
# TODO(decentral1se): implement offset in pyvarint encode/decode
async def recv(self, data: bytes) -> bool:
"""Receive data sent over a channel."""
pass
# TODO(decentral1se): spec out the context manager API of recv
def destroy(self) -> None:
"""Mark message channel as destroyed."""
self.destroyed = True
def encoding_length(self, type:int, message: bytes) -> int:
"""TODO"""
pass