-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Outline of structs as a general 'definition' system (#7069)
## Usage and product changes We introduce the architecture around structs definitions, and definitions in general. The idea of a `definition` is that it is a general schema construct outside the regular `thing` and `type` system - this will initially be used for structs and functions. Definitions are interesting because their interesting payload is in the value, not the key. However, the key contains the ID of the definition. As a result, you can consider the new `DefinitionKey` to be analogous to `TypeVertex`, but the interesting data structure is the `StructDefinition`, which serialises a struct's content. In doing this, we also realise that `ValueType` must encompass the built-in value type category, plus the ID of the struct definition, and create a new `ValueTypeCategory` which can map to a Prefix and doesn't contain the ID of struct definitions. Lastly, we create a the serialised form of `ValueTypeBytes`, which is used as the property of an attribute type's value type, including the definition ID if it exists. ### What isn't implemented yet: 1. The indexing + retrieval by name of value types through the TypeManager 2. Serialisation of `StructDefinition` 3. The data insertion and deletion pattern of struct instantiations
- Loading branch information
1 parent
b7e80e9
commit 67149e1
Showing
24 changed files
with
564 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
|
||
use std::collections::HashMap; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use encoding::graph::definition::definition_key::DefinitionKey; | ||
use encoding::graph::type_::vertex::TypeVertex; | ||
use resource::constants::encoding::StructFieldIDUInt; | ||
|
||
use crate::thing::value::Value; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct StructValue<'a> { | ||
definition: DefinitionKey<'static>, | ||
|
||
// a map allows empty fields to not be recorded at all | ||
fields: HashMap<StructFieldIDUInt, Value<'a>> | ||
} | ||
|
||
impl<'a> StructValue<'a> { | ||
|
||
pub fn definition_key(&self) -> DefinitionKey<'_> { | ||
self.definition.as_reference() | ||
} | ||
} | ||
|
||
|
||
// TODO: implement serialise/deserialise for the StructValue | ||
// since JSON serialisation seems to be able to handle recursive nesting, it should be able to handle that |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.