From 36f6f889906ab7f1cd16a265fd39ff95802c7825 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Thu, 15 Feb 2024 20:18:45 +0100 Subject: [PATCH] Add change 06 instructions --- how_to/Change_06.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 how_to/Change_06.md diff --git a/how_to/Change_06.md b/how_to/Change_06.md new file mode 100644 index 0000000..707e6f9 --- /dev/null +++ b/how_to/Change_06.md @@ -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.