pub struct API {
pub conn: Connection,
pub buf: Vec<u8>,
}
Expand description
Wrapper for the FAH API. Use API::connect_timeout() to initialize.
Example
fn example() -> fahapi::Result<()> {
let mut api = fahapi::API::connect_timeout(&fahapi::DEFAULT_ADDR, std::time::Duration::from_secs(1))?;
api.pause_all()?;
api.unpause_all()
}
Fields§
§conn: Connection
§buf: Vec<u8>
Implementations§
Source§impl API
impl API
Sourcepub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> Result<API>
pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> Result<API>
Connects to your FAH client with a timeout. DEFAULT_ADDR
is the default address.
Sourcepub fn log_updates(&mut self, arg: LogUpdatesArg) -> Result<String>
pub fn log_updates(&mut self, arg: LogUpdatesArg) -> Result<String>
Enables or disables log updates. Returns current log.
Sourcepub fn screensaver(&mut self) -> Result<()>
pub fn screensaver(&mut self) -> Result<()>
Unpauses all slots which are paused waiting for a screensaver and pause them again on disconnect.
Sourcepub fn configured(&mut self) -> Result<bool>
pub fn configured(&mut self) -> Result<bool>
Returns true if the client has set a user, team or passkey.
Sourcepub fn finish_slot(&mut self, slot: i64) -> Result<()>
pub fn finish_slot(&mut self, slot: i64) -> Result<()>
Pauses a slot when its current work unit is completed.
Sourcepub fn finish_all(&mut self) -> Result<()>
pub fn finish_all(&mut self) -> Result<()>
Pauses all slots one-by-one when their current work unit is completed.
Sourcepub fn info(&mut self) -> Result<Vec<Vec<Value>>>
pub fn info(&mut self) -> Result<Vec<Vec<Value>>>
Returns FAH build and machine info. See info_struct()
.
Sourcepub fn info_struct(&mut self) -> Result<Info>
pub fn info_struct(&mut self) -> Result<Info>
Converts Info() data into a structure. Consider this interface to be very unstable.
Sourcepub fn on_idle_all(&mut self) -> Result<()>
pub fn on_idle_all(&mut self) -> Result<()>
Sets all slots to run only when idle.
Sourcepub fn options_get(&mut self) -> Result<Options>
pub fn options_get(&mut self) -> Result<Options>
Returns the FAH client options.
Sourcepub fn options_set<N>(&mut self, key: &str, value: N) -> Result<()>where
N: Display,
pub fn options_set<N>(&mut self, key: &str, value: N) -> Result<()>where
N: Display,
Sets an option.
Sourcepub fn pause_slot(&mut self, slot: i64) -> Result<()>
pub fn pause_slot(&mut self, slot: i64) -> Result<()>
Pauses a slot.
pub fn ppd(&mut self) -> Result<f64>
Sourcepub fn queue_info(&mut self) -> Result<Vec<SlotQueueInfo>>
pub fn queue_info(&mut self) -> Result<Vec<SlotQueueInfo>>
Returns info about the current work unit.
Sourcepub fn request_id(&mut self) -> Result<()>
pub fn request_id(&mut self) -> Result<()>
Requests an ID from the assignment server.
Sourcepub fn request_ws(&mut self) -> Result<()>
pub fn request_ws(&mut self) -> Result<()>
Requests work server assignment from the assignment server.
Sourcepub fn simulation_info(&mut self, slot: i64) -> Result<SimulationInfo>
pub fn simulation_info(&mut self, slot: i64) -> Result<SimulationInfo>
Returns the simulation information for a slot.
Sourcepub fn slot_delete(&mut self, slot: i64) -> Result<()>
pub fn slot_delete(&mut self, slot: i64) -> Result<()>
Deletes a slot.
Sourcepub fn slot_options_get(&mut self, slot: i64) -> Result<SlotOptions>
pub fn slot_options_get(&mut self, slot: i64) -> Result<SlotOptions>
Returns slot options.
Sourcepub fn slot_options_set<N>(
&mut self,
slot: i64,
key: &str,
value: N,
) -> Result<()>where
N: Display,
pub fn slot_options_set<N>(
&mut self,
slot: i64,
key: &str,
value: N,
) -> Result<()>where
N: Display,
Sets slot option.
Sourcepub fn unpause_all(&mut self) -> Result<()>
pub fn unpause_all(&mut self) -> Result<()>
Unpauses all slots.
Sourcepub fn unpause_slot(&mut self, slot: i64) -> Result<()>
pub fn unpause_slot(&mut self, slot: i64) -> Result<()>
Unpauses a slot.
Sourcepub fn uptime(&mut self) -> Result<FAHDuration>
pub fn uptime(&mut self) -> Result<FAHDuration>
Returns FAH uptime.
Sourcepub fn wait_for_units(&mut self) -> Result<()>
pub fn wait_for_units(&mut self) -> Result<()>
Blocks until all slots are paused.