Add Serialize/Deserialize for InterfaceType, RecordType and Vec1

This commit is contained in:
folex 2020-06-22 16:46:11 +03:00
parent 567bec274b
commit add53640f1
2 changed files with 5 additions and 3 deletions

View File

@ -1,9 +1,10 @@
//! This module defines the WIT types.
use crate::vec1::Vec1;
use serde::{Serialize, Deserialize};
/// Represents the types supported by WIT.
#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
pub enum InterfaceType {
/// A 8-bits signed integer.
S8,
@ -52,7 +53,7 @@ pub enum InterfaceType {
}
/// Represents a record type.
#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
pub struct RecordType {
/// Types representing the fields.
/// A record must have at least one field, hence the

View File

@ -5,10 +5,11 @@ use std::{
fmt::{self, Debug},
ops,
};
use serde::{Serialize, Deserialize};
/// `Vec1<T>` represents a non-empty `Vec<T>`. It derefs to `Vec<T>`
/// directly.
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Serialize, Deserialize)]
pub struct Vec1<T>(Vec<T>)
where
T: Debug;