Skip to content

Commit

Permalink
Rename structure --> schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jhugman committed Nov 30, 2023
1 parent bd59b3c commit 71e359e
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 81 deletions.
4 changes: 2 additions & 2 deletions components/support/nimbus-fml/src/client/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ impl FmlFeatureInspector {
self.get_first_error(string).map(|e| vec![e])
}

pub fn get_structure_hash(&self) -> String {
pub fn get_schema_hash(&self) -> String {
self.manifest
.get_structure_hash(&self.feature_id)
.get_schema_hash(&self.feature_id)
.unwrap_or_default()
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/support/nimbus-fml/src/fml.udl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ interface FmlFeatureInspector {
// If this hash changes for a given feature then it is almost
// certain that the code which uses this configuration will also have
// changed.
string get_structure_hash();
string get_schema_hash();
};

dictionary FmlEditorError {
Expand Down
16 changes: 8 additions & 8 deletions components/support/nimbus-fml/src/intermediate_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::defaults::{DefaultsMerger, DefaultsValidator};
use crate::error::FMLError::InvalidFeatureError;
use crate::error::{FMLError, Result};
use crate::frontend::{AboutBlock, FeatureMetadata};
use crate::structure::{StructureHasher, StructureValidator};
use crate::schema::{SchemaHasher, SchemaValidator};
use crate::util::loaders::FilePath;
use anyhow::{bail, Error, Result as AnyhowResult};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -302,7 +302,7 @@ impl FeatureManifest {

pub fn validate_manifest(&self) -> Result<()> {
// We then validate that each type_ref is valid
self.validate_structure()?;
self.validate_schema()?;
self.validate_defaults()?;

// Validating the imported manifests.
Expand All @@ -314,8 +314,8 @@ impl FeatureManifest {
Ok(())
}

fn validate_structure(&self) -> Result<(), FMLError> {
let validator = StructureValidator::new(&self.enum_defs, &self.obj_defs);
fn validate_schema(&self) -> Result<(), FMLError> {
let validator = SchemaValidator::new(&self.enum_defs, &self.obj_defs);
for object in self.iter_object_defs() {
validator.validate_object_def(object)?;
}
Expand Down Expand Up @@ -457,18 +457,18 @@ impl FeatureManifest {
Ok(feature_def)
}

pub fn get_structure_hash(&self, feature_name: &str) -> Result<String> {
pub fn get_schema_hash(&self, feature_name: &str) -> Result<String> {
let (manifest, feature_def) = self
.find_feature(feature_name)
.ok_or_else(|| InvalidFeatureError(feature_name.to_string()))?;

Ok(manifest.feature_structure_hash(feature_def))
Ok(manifest.feature_schema_hash(feature_def))
}
}

impl FeatureManifest {
pub(crate) fn feature_structure_hash(&self, feature_def: &FeatureDef) -> String {
let hasher = StructureHasher::new(&self.enum_defs, &self.obj_defs);
pub(crate) fn feature_schema_hash(&self, feature_def: &FeatureDef) -> String {
let hasher = SchemaHasher::new(&self.enum_defs, &self.obj_defs);
let hash = hasher.hash(feature_def) & 0xffffffff;
format!("{hash:x}")
}
Expand Down
2 changes: 1 addition & 1 deletion components/support/nimbus-fml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod error;
pub(crate) mod frontend;
pub mod intermediate_representation;
pub mod parser;
pub(crate) mod structure;
pub(crate) mod schema;
pub mod util;

cfg_if::cfg_if! {
Expand Down
2 changes: 1 addition & 1 deletion components/support/nimbus-fml/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod fixtures;
mod frontend;
mod intermediate_representation;
mod parser;
mod structure;
mod schema;
mod util;

use anyhow::Result;
Expand Down

0 comments on commit 71e359e

Please sign in to comment.