amazon-ion / ion-schema-rust

Rust implementation of Ion Schema
https://amazon-ion.github.io/ion-schema/sandbox
Apache License 2.0
12 stars 6 forks source link

Shouldn't the ion_schema::violation be `pub`? #135

Closed dlurton closed 1 year ago

dlurton commented 1 year ago

It's currently not pub. This prevents ion_schema::violation::Violation from being referenced explicitly in customer code.

The impact is that the customer code cannot reference the type explicitly. For instance this code works fine:

let type_ref: TypeRef = ...;
let r = type_ref.validate(some_element);
let e = r.unwrap_err();
// e can be used normally

But try to declare an explicit type for e:

let e: ion_schema::violation::Violation = r.unwrap_err();
//                 ^ error, mod is private

use ion_schema::violation::Violation doesn't work either.

TBH, it's a bit surprising to me that Rust allows you to return a type from Type_Ref::validate() that isn't in a public module.

desaikd commented 1 year ago

Fixed with #139