refactor result classes and code which stores/loads results from storage
diff --git a/wally/istorable.py b/wally/istorable.py
new file mode 100644
index 0000000..467f901
--- /dev/null
+++ b/wally/istorable.py
@@ -0,0 +1,31 @@
+import abc
+from typing import Any, Union, List, Dict
+
+
+class IStorable(metaclass=abc.ABCMeta):
+ """Interface for type, which can be stored"""
+
+ @abc.abstractmethod
+ def raw(self) -> Dict[str, Any]:
+ pass
+
+ @abc.abstractclassmethod
+ def fromraw(cls, data: Dict[str, Any]) -> 'IStorable':
+ pass
+
+
+class Storable(IStorable):
+ """Default implementation"""
+
+ def raw(self) -> Dict[str, Any]:
+ return self.__dict__
+
+ @classmethod
+ def fromraw(cls, data: Dict[str, Any]) -> 'IStorable':
+ obj = cls.__new__(cls)
+ obj.__dict__.update(data)
+ return obj
+
+
+Basic = Union[int, str, bytes, bool, None]
+StorableType = Union[IStorable, Dict[str, Any], List[Any], int, str, bytes, bool, None]