Skip to content

Commit

Permalink
Renames get_local_imported_type back to get_type
Browse files Browse the repository at this point in the history
  • Loading branch information
desaikd committed Aug 21, 2024
1 parent 36ee0f8 commit 8f4a118
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ion-schema-tests-runner/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ fn generate_preamble(root_dir_path: &Path) -> TokenStream {
/// Asserts that a value is or is not valid for a given ISL type.
fn __assert_value_validity_for_type(value_ion: &str, schema_id: &str, type_id: &str, expect_valid: bool) -> Result<(), String> {
let schema = __new_schema_system().load_schema(schema_id).unwrap();
let isl_type = schema.get_local_or_imported_type(type_id).unwrap();
let isl_type = schema.get_type(type_id).unwrap();
let value: ion_rs::element::Element = ion_rs::element::Element::read_one(value_ion.as_bytes()).unwrap();
let prepared_value: ion_schema::IonSchemaElement = if value.annotations().contains("document") && value.ion_type() == ion_rs::IonType::SExp {
let element_vec = value.as_sequence()
Expand Down
5 changes: 1 addition & 4 deletions ion-schema/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ fn validate(command_args: &ArgMatches) -> IonSchemaResult<()> {
let schema = schema_system.load_schema(schema_id);

// get the type provided by user from the schema file
let type_ref = schema
.unwrap()
.get_local_or_imported_type(schema_type)
.unwrap();
let type_ref = schema.unwrap().get_type(schema_type).unwrap();

// create a text writer to make the output
let mut output = vec![];
Expand Down
2 changes: 1 addition & 1 deletion ion-schema/src/isl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
//! assert!(schema.is_ok());
//!
//! // verify if the generated schema contains the correct type
//! assert!(schema.unwrap().get_local_or_imported_type("my_type_name").is_some())
//! assert!(schema.unwrap().get_type("my_type_name").is_some())
//! ```
//!
//! ## Example of serializing a programmatically constructed schema into a schema file:
Expand Down
2 changes: 1 addition & 1 deletion ion-schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Schema {

/// Returns the requested type, if present in this schema or a a built in type or imported in the schema;
/// otherwise returns None.
pub fn get_local_or_imported_type<A: AsRef<str>>(&self, name: A) -> Option<TypeDefinition> {
pub fn get_type<A: AsRef<str>>(&self, name: A) -> Option<TypeDefinition> {
let type_id = self.types.get_type_id_by_name(name.as_ref())?;
Some(TypeDefinition::new(*type_id, Arc::clone(&self.types)))
}
Expand Down
5 changes: 1 addition & 4 deletions ion-schema/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,10 +1437,7 @@ mod schema_system_tests {
.unwrap()
.get_built_in_or_defined_type("my_number");
assert!(isl_defined_type.is_some());
let isl_type = schema
.as_ref()
.unwrap()
.get_local_or_imported_type("my_decimal");
let isl_type = schema.as_ref().unwrap().get_type("my_decimal");
assert!(isl_type.is_some());
}

Expand Down
2 changes: 1 addition & 1 deletion ion-schema/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl TypeDefinition {
/// let schema = schema_system.load_schema("sample.isl")?;
///
/// // unwrap() here because we know that the `my_int` type exists in sample.isl
/// let type_ref = schema.get_local_or_imported_type("my_int").unwrap();
/// let type_ref = schema.get_type("my_int").unwrap();
///
/// assert!(type_ref.validate(&owned_element).is_ok()); // 4 is valid for `my_int`
/// assert!(type_ref.validate(&document).is_err()); // document type is invalid for `my_int` type
Expand Down
2 changes: 1 addition & 1 deletion wasm-schema-sandbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub fn validate(
log!("loaded schema successfully!");

// Retrieve a particular type from this schema
let type_ref_result: Option<TypeDefinition> = schema.get_local_or_imported_type(schema_type);
let type_ref_result: Option<TypeDefinition> = schema.get_type(schema_type);

let type_ref = match &type_ref_result {
Some(type_ref) => type_ref,
Expand Down

0 comments on commit 8f4a118

Please sign in to comment.