Skip to content

Conversation

@AlixANNERAUD
Copy link
Contributor

@AlixANNERAUD AlixANNERAUD commented Dec 13, 2025

This pull request refactors the device control interface across multiple drivers and modules to use a new, more type-safe command system based on ControlCommandIdentifier and the AnyByLayout type for input/output arguments. It replaces the older ControlCommand/ControlArgument approach with a pattern that enables better compile-time checks, clearer intent, and easier extensibility. Additionally, it updates related command definitions and device implementations to match the new interface, and cleans up some memory manager functions.

Device control interface refactor:

  • Refactored all device control methods (e.g., in screen.rs, hash.rs, console.rs, drive_file.rs, canvas_screen.rs, and traits.rs) to use ControlCommandIdentifier and typed input/output via AnyByLayout, replacing the use of ControlCommand and ControlArgument. This enables more robust and type-safe device command handling. [1] [2] [3] [4] [5] [6] [7] [8]
  • Updated device command matching to use the new IDENTIFIER constants and added helper methods like cast_input and cast_output for extracting typed arguments from AnyByLayout. [1] [2] [3] [4] [5] [6]

Command definition improvements:

  • Replaced manual command definitions with the define_command! macro for commands like RESET, SET_ALGORITHM, and GET_MAIN_FUNCTION, improving clarity and reducing boilerplate. [1] [2]
  • Updated all usages of these commands throughout the codebase to use the new macro-generated forms and signatures. [1] [2]

API and dependency updates:

  • Updated Cargo.toml files to add shared as a workspace dependency where needed for the new shared types. [1] [2]
  • Updated imports in affected files to use the new types and command identifiers. [1] [2] [3] [4] [5] [6] [7]

Memory manager cleanup:

  • Removed unnecessary unsafe from get_used and get_free methods in memory manager implementations for both std and wasm targets. [1] [2] [3]

ABI and FFI adjustments:

  • Updated FFI boundary code to use the new control interface, e.g., in xila_file_system_is_a_terminal, now passing &() and using the new output conventions.

This refactor modernizes the device control API, making it safer and easier to maintain, and brings consistency to command handling across the codebase.

…ices with improved type safety and output management
…fier and AnyByLayout for improved type safety
@AlixANNERAUD AlixANNERAUD linked an issue Dec 13, 2025 that may be closed by this pull request
@AlixANNERAUD AlixANNERAUD merged commit acf1ccc into main Dec 13, 2025
1 check passed
@AlixANNERAUD AlixANNERAUD deleted the 152-refactor-control-command-handling branch December 13, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor control command handling

2 participants