Struct API

Source
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

Source

pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> Result<API>

Connects to your FAH client with a timeout. DEFAULT_ADDR is the default address.

Source

pub fn help(&mut self) -> Result<String>

Returns a listing of the FAH API commands.

Source

pub fn log_updates(&mut self, arg: LogUpdatesArg) -> Result<String>

Enables or disables log updates. Returns current log.

Source

pub fn screensaver(&mut self) -> Result<()>

Unpauses all slots which are paused waiting for a screensaver and pause them again on disconnect.

Source

pub fn always_on(&mut self, slot: i64) -> Result<()>

Sets a slot to be always on.

Source

pub fn configured(&mut self) -> Result<bool>

Returns true if the client has set a user, team or passkey.

Source

pub fn do_cycle(&mut self) -> Result<()>

Runs one client cycle.

Source

pub fn finish_slot(&mut self, slot: i64) -> Result<()>

Pauses a slot when its current work unit is completed.

Source

pub fn finish_all(&mut self) -> Result<()>

Pauses all slots one-by-one when their current work unit is completed.

Source

pub fn info(&mut self) -> Result<Vec<Vec<Value>>>

Returns FAH build and machine info. See info_struct().

Source

pub fn info_struct(&mut self) -> Result<Info>

Converts Info() data into a structure. Consider this interface to be very unstable.

Source

pub fn num_slots(&mut self) -> Result<i64>

Returns the number of slots.

Source

pub fn on_idle(&mut self, slot: i64) -> Result<()>

Sets a slot to run only when idle.

Source

pub fn on_idle_all(&mut self) -> Result<()>

Sets all slots to run only when idle.

Source

pub fn options_get(&mut self) -> Result<Options>

Returns the FAH client options.

Source

pub fn options_set<N>(&mut self, key: &str, value: N) -> Result<()>
where N: Display,

Sets an option.

Source

pub fn pause_all(&mut self) -> Result<()>

Pauses all slots.

Source

pub fn pause_slot(&mut self, slot: i64) -> Result<()>

Pauses a slot.

Source

pub fn ppd(&mut self) -> Result<f64>

Source

pub fn queue_info(&mut self) -> Result<Vec<SlotQueueInfo>>

Returns info about the current work unit.

Source

pub fn request_id(&mut self) -> Result<()>

Requests an ID from the assignment server.

Source

pub fn request_ws(&mut self) -> Result<()>

Requests work server assignment from the assignment server.

Source

pub fn shutdown(&mut self) -> Result<()>

Ends all FAH processes.

Source

pub fn simulation_info(&mut self, slot: i64) -> Result<SimulationInfo>

Returns the simulation information for a slot.

Source

pub fn slot_delete(&mut self, slot: i64) -> Result<()>

Deletes a slot.

Source

pub fn slot_info(&mut self) -> Result<Vec<SlotInfo>>

Returns information about each slot.

Source

pub fn slot_options_get(&mut self, slot: i64) -> Result<SlotOptions>

Returns slot options.

Source

pub fn slot_options_set<N>( &mut self, slot: i64, key: &str, value: N, ) -> Result<()>
where N: Display,

Sets slot option.

Source

pub fn unpause_all(&mut self) -> Result<()>

Unpauses all slots.

Source

pub fn unpause_slot(&mut self, slot: i64) -> Result<()>

Unpauses a slot.

Source

pub fn uptime(&mut self) -> Result<FAHDuration>

Returns FAH uptime.

Source

pub fn wait_for_units(&mut self) -> Result<()>

Blocks until all slots are paused.

Trait Implementations§

Source§

impl Debug for API

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for API

§

impl RefUnwindSafe for API

§

impl Send for API

§

impl Sync for API

§

impl Unpin for API

§

impl UnwindSafe for API

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.