mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
25 lines
709 B
Python
25 lines
709 B
Python
|
class Request:
|
||
|
"""A request sent from a :py:class:`Link` to another.
|
||
|
|
||
|
It contains the name of the requested handler, in addition to the data."""
|
||
|
|
||
|
def __init__(self, handler: str, data: dict):
|
||
|
super().__init__()
|
||
|
self.handler: str = handler
|
||
|
self.data: dict = data
|
||
|
|
||
|
def to_dict(self):
|
||
|
return self.__dict__
|
||
|
|
||
|
@staticmethod
|
||
|
def from_dict(d: dict):
|
||
|
return Request(**d)
|
||
|
|
||
|
def __eq__(self, other):
|
||
|
if isinstance(other, Request):
|
||
|
return self.handler == other.handler and self.data == other.data
|
||
|
return False
|
||
|
|
||
|
def __repr__(self):
|
||
|
return f"{self.__class__.__qualname__}(handler={self.handler}, data={self.data})"
|