HalPin

Trait HalPin 

Source
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§

Source

type Storage: Debug

The underlying storage type for the given pin

This will usually be a scalar value such as u32 or bool

Required Methods§

Source

fn name(&self) -> &str

Get the pin’s name

Source

fn storage_mut(&self) -> Result<&mut Self::Storage, StorageError>

Get a mutable pointer to underlying shared memory storing this pin’s value

Source

fn storage(&self) -> Result<&Self::Storage, StorageError>

Get a reference to the underlying shared memory storing the pin’s value

Source

fn register( full_pin_name: &str, component_id: i32, ) -> Result<Self, PinRegisterError>

Register the pin with the LinuxCNC HAL

Returns a raw pointer to the underling HAL shared memory for the pin

Provided Methods§

Source

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.

Implementors§