-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discrete model connector input types #1
Conversation
This commit removes a need to define a global Message enum type and allows Models to handle any event type. It doesn't compile yet though: - Didn't work out lifetimes fully It also doesn't do all that I want it to: - Models should allow generic inputs and outputs - e.g. a buffer model should allow for type arg T which gets stored in a queue, not sure how that works out with the current system. What IS handled is type erasure of model inputs and outputs, which prevents having to specialize a lot of structures used by the simulation to end-user defined Message types. This makes the library defined model components easier to use in conjunction with multiple crates defining their own models. Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
Fix a typo Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
a09bcd2
to
cdf5b49
Compare
Init macro crate Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
cdf5b49
to
eb30a3b
Compare
Make model handle erased handlers Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
Current implementation requires specifying that 's: 'static which isn't correct. Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
Add ModelStore struct for easier management of models Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
0e574fd
to
c59cc8b
Compare
Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
This change required Model output_connectors to return a non-static type. Created a Queue model to try out type resolution. Seems to compile fine. Removed Pin from Event data as Events should be unique and not moved from within handlers. I'll see how that works out with type erasure when I get to that. Made OutputConnectorInfo briefer to construct. Returned docs where they belong. Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
The described behavior has been achieved by erasing connector types before they're attached to models, which avoids the need for HeterogeneousTuple type which was hard to reason with on type system level. While the current implementation is more verbose, it's A LOT easier to implement as it doesn't require compiler extensions and nowhere near as many unstable Rust features. Impl of Models is simplified by using a proc_macro. |
Simulation shouldn't care about event types models receive past the validation step.
TypeId
s.Models should be able to take in (virtually) any number of inputs and provide any number of output lanes.
Models are
'static
, as are input and output declarations. This restriction is necessary as changing input and output counts/types while a simulation is running makes it incredibly cumbersome to detect changes and handle model validation which would slow down the simulation for most normal use cases.Erasing model inputs and outputs sacrifices performance when compared to previous design due to additional vtable lookups (untested), but vastly improves: DX, (incremental) compilation time and simplicity of the implementation.
Modelling inputs as a struct bears the limitation of requiring all inputs to be provided at once or user facing code having to shift through multiple
Option
wrapped values which isn't the nicest interface. And given that a macro can generate several traits to support a much nicer interface at the cost of very little compile time, usingHeterogeneousTuple
seems like a much nicer approach.HeterogeneousTuple
works much like variadic generics would anyway so it provides a nicer transition trajectory for adaptation of existing code base once Rust gets them.HeterogeneousTuple
approach depends onspecialization
,auto_traits
, andnegative_impls
unstable features to work.And finally, user facing code should be straightforward to implement which means: