857 B
- data: Add types to objects
As we will soon see, there will be different logical types of objects that are used in different contexts (even though, from the Object Database’s point of view, they are just all bytes). In order to lower the chance of using an object in the wrong context we’re going to add a type tag for each object.
The type is just a string that’s going to be prepended to the start of the file, followed by a null byte. When reading the file later we’ll extract the type and verify that it’s indeed the expected type.
The default type is going to be blob
, since by default
an object is a collection of bytes with no further semantic meaning.
We can also pass expected=None
to
get_object()
if we don’t want to verify the type. This is
useful for the cat-file
CLI command which is a debug
command used for printing all objects.