Brainstorm initial API and modify db to be more FUSE friendly

This commit is contained in:
Andrew Mulbrook 2026-03-16 01:14:07 -05:00
parent 0a444a55c4
commit 96c9e62354
3 changed files with 183 additions and 105 deletions

View file

@ -15,8 +15,8 @@ class Tree:
Initialize a Tree. If data is provided, deserialize from UTF-8 JSON bytes.
An empty Tree is created if data is None.
"""
if data is None:
self._entries: dict[str, str] = {}
if not data:
self._entries: dict[str, int] = {}
else:
self._entries = json.loads(data.decode("utf-8"))
@ -24,14 +24,18 @@ class Tree:
"""Serialize the tree to UTF-8 JSON bytes."""
return json.dumps(self._entries).encode("utf-8")
def set_entry(self, name: str, uuid: str) -> None:
def set_entry(self, name: str, object_id: int) -> None:
"""Add or update an entry mapping name -> uuid."""
self._entries[name] = uuid
self._entries[name] = object_id
def get_entry(self, name: str) -> int:
"""Get the uuid associated with a name, or raise KeyError if not found."""
return self._entries[name]
def rm_entry(self, name: str) -> None:
"""Remove an entry by name. Raises KeyError if not found."""
del self._entries[name]
def list(self) -> dict[str, str]:
def list(self) -> dict[str, int]:
"""Return a shallow copy of all entries as {name: uuid}."""
return dict(self._entries)