Trait linuxcnc_hal::hal_pin::HalPin
source · pub trait HalPin: Sized {
type Storage: Debug;
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>;
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()
.