Add change 06 instructions

This commit is contained in:
David Doblas Jiménez 2024-02-15 20:18:45 +01:00
parent a010615cf2
commit 36f6f88990
1 changed files with 17 additions and 0 deletions

17
how_to/Change_06.md Normal file
View File

@ -0,0 +1,17 @@
- 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.