Skip to content

Split Serialization and Deserialization #201

Description

currently for a Parsable it has to implement both serialization and deserialization, and while technically there are work arounds to only implement on or the other within golang it's preferred to have an interface only implement what is minimally required.

current:

// Parsable defines a serializable model object.
type Parsable interface {
	// Serialize writes the objects properties to the current writer.
	Serialize(writer SerializationWriter) error
	// GetFieldDeserializers returns the deserialization information for this object.
	GetFieldDeserializers() map[string]func(ParseNode) error
}

proposed:

// Serializable defines a model that can be serialized
type Serializable interface {
	// Serialize writes the objects properties to the current writer.
	Serialize(writer SerializationWriter) error
}

// Deserializable defines a model that can be deserialized
type Deserializable interface {
	// GetFieldDeserializers returns the deserialization information for this object.
	GetFieldDeserializers() map[string]func(ParseNode) error
}

// for compatibility
// Parsable defines a serializable model object.
type Parsable interface {
	Serializable
	Deserializable
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋enhancementNew feature or requestpriority:p3Nice to have. Customer impact is very minimaltype:enhancementEnhancement request targeting an existing experience

    Projects

    • Status
      Waits for author 🔁

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions