Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document type design #378

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Add document type design #378

wants to merge 2 commits into from

Conversation

JordonPhillips
Copy link
Contributor

This adds a full design document for document types.

Note that this is a bit of a rough draft at the moment but I wanted to get it up sooner rather than later, and it nevertheless should convey all of the necessary information if not in an ideal order.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@JordonPhillips JordonPhillips requested a review from a team as a code owner February 12, 2025 16:33
>>> document.as_shape(registry.get(document.discriminator))
```

##### Type Registries
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design for these probably goes in the serialization document, but I wanted to have it here for now for the sake of making the review easier.

def discriminator(self) -> ShapeID:
...

def is_none(self) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need for an explicit value type to hold None? Could this just be None itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It lets you distinguish between null and unset

def as_blob(self) -> bytes:
...

def as_boolean(self) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to imagine how a lot of this will be used- maybe it will become clearer as the document goes on, but what is the intended use for the methods like as_boolean or as_float?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They return the expected type. If the underlying data isn't compatible, an error is thrown. This can include things like converting a base64 string into bytes for a JSON document when as_bytes is called.

This adds a full design document for document types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants