Skip to content

Question: Best approach for polymorphic members #91

Description

@cobalthex

This isn't an issue but a question:

I have a struct something like

#[derive(Encode, Decode)]
struct Foo
{
   .. members
  blah: Box<[Box<dyn T>]>,
}

my current approach is to have a 'serializing' version of this struct like:

struct DynType { type_id: u64, size: u64 }
struct FooFile
{
  .. members
  blah: &[DynType],
  blah_data: &[u8],
}

where blah's values are stored in blah_data and as bitcode-encoded values linearly written into a byte buf

Is this a reasonable approach? Is there a more efficient approach?

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

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions