pub struct Driver {
pub buttplug: Arc<ButtplugClient>,
/* private fields */
}Expand description
Driver that can send patterns to buttplug devices.
Fields§
§buttplug: Arc<ButtplugClient>Implementations§
Source§impl Driver
impl Driver
Sourcepub fn new<P: 'static + Pattern>(bp: Arc<ButtplugClient>, pattern: P) -> Self
pub fn new<P: 'static + Pattern>(bp: Arc<ButtplugClient>, pattern: P) -> Self
Creates a new driver with a given ButtplugClient and Pattern.
The ButtplugClient is passed via an Arc to allow for applications to maintain access to the client after the driver has been created.
Sourcepub fn set_tickrate(&mut self, hz: u64) -> &mut Self
pub fn set_tickrate(&mut self, hz: u64) -> &mut Self
Sets the tickrate of the driver, in Hz. The tickrate is the number of times per second that the driver samples the pattern and sends the new intensity to the device.
The default tickrate is 10 Hz.
Sourcepub fn set_pattern<P: 'static + PatternGenerator>(
&mut self,
pattern: P,
) -> &mut Self
pub fn set_pattern<P: 'static + PatternGenerator>( &mut self, pattern: P, ) -> &mut Self
Sets the global pattern of the driver. This pattern is applied to all actuators on all devices that do not have a more specific pattern.
Sourcepub fn set_device_pattern<P: 'static + PatternGenerator>(
&mut self,
device_id: u32,
pattern: P,
) -> &mut Self
pub fn set_device_pattern<P: 'static + PatternGenerator>( &mut self, device_id: u32, pattern: P, ) -> &mut Self
Sets the pattern of a specific device based on its index.
Device indexes can be found using the index() method of the ButtplugClientDevice.
Sourcepub fn remove_device_pattern(&mut self, device_id: u32) -> &mut Self
pub fn remove_device_pattern(&mut self, device_id: u32) -> &mut Self
Removes the pattern of a specific device based on its ID.
Sourcepub fn set_actuator_pattern<P: 'static + PatternGenerator>(
&mut self,
device_id: u32,
actuator_id: u32,
pattern: P,
) -> &mut Self
pub fn set_actuator_pattern<P: 'static + PatternGenerator>( &mut self, device_id: u32, actuator_id: u32, pattern: P, ) -> &mut Self
Sets the pattern of a specific actuator based on its device ID and actuator ID.
Sourcepub fn remove_actuator_pattern(
&mut self,
device_id: u32,
actuator_id: u32,
) -> &mut Self
pub fn remove_actuator_pattern( &mut self, device_id: u32, actuator_id: u32, ) -> &mut Self
Removes the pattern of a specific actuator based on its device and actuator ID.
Sourcepub async fn run(&mut self) -> Result<(), ButtplugClientError>
pub async fn run(&mut self) -> Result<(), ButtplugClientError>
Runs the driver, actuating all connected devices with the current pattern. All devices will stop when run exits.
Sourcepub async fn run_while(
&mut self,
running: AtomicBool,
) -> Result<(), ButtplugClientError>
pub async fn run_while( &mut self, running: AtomicBool, ) -> Result<(), ButtplugClientError>
Runs the driver, actuating all connected devices with the current pattern, while the running is true.
This is useful for when you want to cancel the driver early. All devices will stop when run_while exits.