Struct HalComponent

Source
pub struct HalComponent<R> { /* private fields */ }
Expand description

HAL component

The main HAL component interface. See the crate documentation for examples.

During registraton, all resource names are prefixed with the component name and a . full stop character. For example, a component named rust-comp with a pin named input-1 will show up in LinuxCNC as a pin called rust-comp.input-1.

HalComponent has a custom Drop implementation which calls hal_exit (among other things) when the variable holding the component goes out of scope. Due to this, the component should be initialised in main() so it lives for the entire life of the program.

Implementations§

Source§

impl<R> HalComponent<R>
where R: Resources,

Source

pub fn new(name: &'static str) -> Result<Self, ComponentInitError>

Create a new HAL component

new registers a new HAL component with LinuxCNC, registers the required UNIX signal handlers and allocates resources (pins, signals, etc) required by the component.

Source

pub fn id(&self) -> i32

Get the HAL-assigned ID for this component

Source

pub fn name(&self) -> &str

Get the component name

Source

pub fn should_exit(&self) -> bool

Check whether the component was signalled to shut down

Source

pub fn resources(&self) -> &R

Get a reference to the component’s resources

Trait Implementations§

Source§

impl<R: Debug> Debug for HalComponent<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R> Drop for HalComponent<R>

Source§

fn drop(&mut self)

Clean up resources, signals and HAL component

Auto Trait Implementations§

§

impl<R> !Freeze for HalComponent<R>

§

impl<R> !RefUnwindSafe for HalComponent<R>

§

impl<R> Send for HalComponent<R>
where R: Send,

§

impl<R> !Sync for HalComponent<R>

§

impl<R> Unpin for HalComponent<R>
where R: Unpin,

§

impl<R> !UnwindSafe for HalComponent<R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.