Trait rust_dmx::DmxPort

source ·
pub trait DmxPort: Display + Serialize + Deserialize {
    // Required methods
    fn available_ports() -> Result<Vec<Box<dyn DmxPort>>>
       where Self: Sized;
    fn open(&mut self) -> Result<(), OpenError>;
    fn close(&mut self);
    fn write(&mut self, frame: &[u8]) -> Result<(), WriteError>;
}
Expand description

Trait for the general notion of a DMX port. This enables creation of an “offline” port to slot into place if an API requires an output.

Required Methods§

source

fn available_ports() -> Result<Vec<Box<dyn DmxPort>>>
where Self: Sized,

Return the available ports. The ports will need to be opened before use.

source

fn open(&mut self) -> Result<(), OpenError>

Open the port for writing. Implementations should no-op if this is called twice rather than returning an error. Primarily used to re-open a port that has be deserialized.

source

fn close(&mut self)

Close the port.

source

fn write(&mut self, frame: &[u8]) -> Result<(), WriteError>

Write a DMX frame out to the port. If the frame is smaller than the minimum universe size, it will be padded with zeros. If the frame is larger than the maximum universe size, the values beyond the max size will be ignored.

Trait Implementations§

source§

impl<'typetag> Serialize for dyn DmxPort + 'typetag

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'typetag> Serialize for dyn DmxPort + Send + 'typetag

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'typetag> Serialize for dyn DmxPort + Send + Sync + 'typetag

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'typetag> Serialize for dyn DmxPort + Sync + 'typetag

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Implementors§