Skip to content
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

[struct] Update StructSerializable contract (NFC) #7441

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Marker interface to indicate a class is serializable using Struct serialization.
*
* <p>While this cannot be enforced by the interface, any class implementing this interface should
* provide a public final static `struct` member variable.
* provide a public final static `struct` member variable, or a static final `getProto()` method if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getProto

Should be getStruct, no? And what parameters should this function be allowed to take? If it can be polymorphic (eg Vector declaring a getStruct(Nat<?> rows) and Matrix declaring getStruct(Nat<?> rows, Nat<?> cols)), then there's no standard way for end code to be generic over serializable types - it'd have to hardcode based on known types, and would be unable to support arbitrary/unknown ones. In particular, it would mean epilogue would only be able to support known WPILib types, and nothing defined by users or third party libraries.

Changing this interface to require an instance method would allow for serialization of arbitrary user types. Deserialization would still need to be done through structs instantiated via static factory methods. Such a change would likely be a big lift

public interface StructSerializable<T> {
  Struct<T> getStruct();
}

* the class is generic.
*/
public interface StructSerializable extends WPISerializable {}
Loading