Skip to content
Merged
Next Next commit
Make public fields in scale-info meta type hierarchy
  • Loading branch information
ascjones committed Sep 9, 2020
commit 4132778993c901f1449119a474464997ba26702d
3 changes: 2 additions & 1 deletion src/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct UntrackedSymbol<T> {
id: NonZeroU32,
/// The index to the symbol in the interner table.
pub id: NonZeroU32,
#[serde(skip)]
marker: PhantomData<fn() -> T>,
}
Expand Down
3 changes: 2 additions & 1 deletion src/ty/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
))]
#[serde(rename_all = "lowercase")]
pub struct TypeDefComposite<T: Form = MetaForm> {
/// The fields of the composite type.
#[serde(skip_serializing_if = "Vec::is_empty", default)]
fields: Vec<Field<T>>,
pub fields: Vec<Field<T>>,
}

impl IntoCompact for TypeDefComposite {
Expand Down
4 changes: 2 additions & 2 deletions src/ty/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
pub struct Field<T: Form = MetaForm> {
/// The name of the field. None for unnamed fields.
#[serde(skip_serializing_if = "Option::is_none", default)]
name: Option<T::String>,
pub name: Option<T::String>,
/// The type of the field.
#[serde(rename = "type")]
ty: T::TypeId,
pub ty: T::TypeId,
}

impl IntoCompact for Field {
Expand Down
8 changes: 4 additions & 4 deletions src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ pub use self::{composite::*, fields::*, path::*, variant::*};
pub struct Type<T: Form = MetaForm> {
/// The unique path to the type. Can be empty for built-in types
#[serde(skip_serializing_if = "Path::is_empty", default)]
path: Path<T>,
pub path: Path<T>,
/// The generic type parameters of the type in use. Empty for non generic types
#[serde(rename = "params", skip_serializing_if = "Vec::is_empty", default)]
type_params: Vec<T::TypeId>,
pub type_params: Vec<T::TypeId>,
/// The actual type definition
#[serde(rename = "def")]
type_def: TypeDef<T>,
pub type_def: TypeDef<T>,
}

impl IntoCompact for Type {
Expand Down Expand Up @@ -243,7 +243,7 @@ impl TypeDefTuple {
pub struct TypeDefSequence<T: Form = MetaForm> {
/// The element type of the sequence type.
#[serde(rename = "type")]
type_param: T::TypeId,
pub type_param: T::TypeId,
}

impl IntoCompact for TypeDefSequence {
Expand Down
2 changes: 1 addition & 1 deletion src/ty/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
))]
pub struct Path<T: Form = MetaForm> {
/// The segments of the namespace.
segments: Vec<T::String>,
pub segments: Vec<T::String>,
}

impl<T> Default for Path<T>
Expand Down
9 changes: 5 additions & 4 deletions src/ty/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
))]
#[serde(rename_all = "lowercase")]
pub struct TypeDefVariant<T: Form = MetaForm> {
/// The variants of a variant type
#[serde(skip_serializing_if = "Vec::is_empty", default)]
variants: Vec<Variant<T>>,
pub variants: Vec<Variant<T>>,
}

impl IntoCompact for TypeDefVariant {
Expand Down Expand Up @@ -116,10 +117,10 @@ impl TypeDefVariant {
))]
pub struct Variant<T: Form = MetaForm> {
/// The name of the struct variant.
name: T::String,
pub name: T::String,
/// The fields of the struct variant.
#[serde(skip_serializing_if = "Vec::is_empty", default)]
fields: Vec<Field<T>>,
pub fields: Vec<Field<T>>,
/// The discriminant of the variant.
///
/// # Note
Expand All @@ -128,7 +129,7 @@ pub struct Variant<T: Form = MetaForm> {
/// every C-like enum variant has a discriminant specified
/// upon compile-time.
#[serde(skip_serializing_if = "Option::is_none", default)]
discriminant: Option<u64>,
pub discriminant: Option<u64>,
}

impl IntoCompact for Variant {
Expand Down