pub trait HalPin: Sized {
type Storage: Debug;
// Required methods
fn name(&self) -> &str;
fn storage_mut(&self) -> Result<&mut Self::Storage, StorageError>;
fn storage(&self) -> Result<&Self::Storage, StorageError>;
fn register(
full_pin_name: &str,
component_id: i32,
) -> Result<Self, PinRegisterError>;
// Provided method
fn allocate_storage() -> Result<*mut *mut Self::Storage, StorageError> { ... }
}Expand description
HAL pin trait
Implemented for any HAL pin. Handles allocation of backing storage in LinuxCNC’s memory space.
Required Associated Types§
Required Methods§
Sourcefn storage_mut(&self) -> Result<&mut Self::Storage, StorageError>
fn storage_mut(&self) -> Result<&mut Self::Storage, StorageError>
Get a mutable pointer to underlying shared memory storing this pin’s value
Sourcefn storage(&self) -> Result<&Self::Storage, StorageError>
fn storage(&self) -> Result<&Self::Storage, StorageError>
Get a reference to the underlying shared memory storing the pin’s value
Provided Methods§
Sourcefn allocate_storage() -> Result<*mut *mut Self::Storage, StorageError>
fn allocate_storage() -> Result<*mut *mut Self::Storage, StorageError>
Allocate memory using hal_malloc() for storing pin value in
§Errors
This method will return an Err if hal_malloc() returns a null pointer.
§Safety
This method attempts to allocate memory in LinuxCNC’s shared memory space with the unsafe
method hal_malloc().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.