Struct AsyncTag

Source
pub struct AsyncTag { /* private fields */ }
Expand description

tag entry, represents a tag in PLC controller

Implementations§

Source§

impl AsyncTag

Source

pub fn new<P: Into<Vec<u8>>>(path: P) -> Result<Self>

create instance of AsyncTag

§Tag String Attributes

See https://github.com/libplctag/libplctag/wiki/Tag-String-Attributes for tag string attributes.

Source

pub async fn create<P: Into<Vec<u8>>>(path: P) -> Result<Self>

👎Deprecated: do not need to be async, use new() instead

create instance of AsyncTag

§Tag String Attributes

See https://github.com/libplctag/libplctag/wiki/Tag-String-Attributes for tag string attributes.

Source

pub async fn ready(&mut self) -> Result<()>

wait until created

Source

pub async fn read(&mut self) -> Result<()>

perform read operation.

Source

pub async fn write(&mut self) -> Result<()>

perform write operation

Source

pub fn status(&mut self) -> Status

poll status

Source

pub fn get_attr( &mut self, attr: impl AsRef<str>, default_value: i32, ) -> Result<i32>

get tag attribute

Source

pub fn set_attr(&mut self, attr: impl AsRef<str>, value: i32) -> Result<()>

set tag attribute

Source

pub fn elem_size(&mut self) -> Result<i32>

element size

Source

pub fn elem_count(&mut self) -> Result<i32>

element count

Source

pub fn size(&mut self) -> Result<u32>

tag size in bytes

Source

pub fn set_size(&mut self, size: u32) -> Result<u32>

set tag size in bytes, returns old size

Source

pub fn get_bit(&mut self, bit_offset: u32) -> Result<bool>

get bit value

Source

pub fn set_bit(&mut self, bit_offset: u32, value: bool) -> Result<()>

set bit value

Source

pub fn get_value<T: Decode>(&mut self, byte_offset: u32) -> Result<T>

get value from mem, you should call read() before this operation

Source

pub fn get_value_in_place<T: Decode>( &mut self, byte_offset: u32, place: &mut T, ) -> Result<()>

get value from mem, you should call read() before this operation

Source

pub fn set_value<T: Encode>(&mut self, byte_offset: u32, value: T) -> Result<()>

set value in mem, you should call write() later

Source

pub async fn read_value<T: Decode>(&mut self, offset: u32) -> Result<T>

perform read & returns the value

Source

pub async fn read_value_in_place<T: Decode>( &mut self, offset: u32, place: &mut T, ) -> Result<()>

perform read & returns the value

Source

pub async fn write_value<T: Encode + Send>( &mut self, offset: u32, value: T, ) -> Result<()>

set the value and write to PLC Controller

Source

pub fn get_bytes(&mut self, byte_offset: u32, buf: &mut [u8]) -> Result<usize>

get raw bytes

Source

pub fn get_bytes_unchecked( &self, byte_offset: u32, buf: &mut [u8], ) -> Result<usize>

get raw bytes. If buffer length would exceed the end of the data in the tag data buffer, an out of bounds error is returned

Source

pub fn set_bytes(&mut self, byte_offset: u32, buf: &mut [u8]) -> Result<usize>

set raw bytes

Source

pub fn set_bytes_unchecked( &mut self, byte_offset: u32, buf: &[u8], ) -> Result<usize>

set raw bytes. If buffer length would exceed the end of the data in the tag data buffer, an out of bounds error is returned

Source

pub fn into_raw(self) -> RawTag

take the inner

Trait Implementations§

Source§

impl Debug for AsyncTag

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.