Giter VIP home page Giter VIP logo

Comments (2)

cBournhonesque avatar cBournhonesque commented on June 15, 2024

Some ideas to accomplish this:

  • use bevy_reflect and reflection extensively
  • provide some kind of macro to merge various ComponentProtocols or MessageProtocols into a single enum
  • maybe make it possible for ComponentProtocol to be a struct containing enums (or other structs), and provide function to iterate through the different variants (should be doable)

from lightyear.

cBournhonesque avatar cBournhonesque commented on June 15, 2024

I read a bit more about reflection.
General idea:

  • every Message is registered in the TypeRegistry via Reflection. We also additional type metadata for each message via a TypeData
MessageMetadata {
  frequency: usize
}

Maybe the type data can contain pointers to other useful type functions?
The reflected types might need to have ReflectSerialize and ReflectDeserialize as extra TypeData?

  • the frequency is how much we think we'll write this message. Higher frequency messages need to have their types serialized with fewer bytes.

  • the bevy::reflect ReflectSerializer reflects &dyn Reflect as a type: value value pair, which is not what we want. However it looks like we can use the TypedReflectSerializer, which just serializes the value itself.

  • When we call Protocol::finalize at some point, we go through the registry, get all the types that have MessageMetadata and order them by frequency. Then use Huffman coding to serialize the enum variant, in order to minimize the number of bits written. Maybe have a LightyearSerializer which wraps around TypedReflectSerializer (to have registry access), it starts by serializing the type (With huffman coding) and then serializes the value.

from lightyear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.