Skip to content

derive MaxSize and Size method on the typeΒ #45

@dshulyak

Description

@dshulyak

MaxSize method should estimate the maximum possible size of the struct that needs to be decoded taking into account limits (such as max for the collections). Any value that overflows such MaxSize for the type must be discarded with an error.

Size method is an optimization for Encode. Without Size consumer is forced to allocate memory multiple times for a single encode operation, instead it should be possible to use the following code.

encoder := scale.NewEncoder(bytes.NewBuffer(make([]byte, typed.Size()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    πŸ“‹ Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions