Struct ruci::UciConnection

source ·
pub struct UciConnection<MSend, MReceive>
where MSend: Message, MReceive: Message,
{ pub process: Child, pub stdout: ChildStdout, pub stdin: ChildStdin, /* private fields */ }
Expand description

This is the basis of a UCI connection; use EngineConnection or GuiConnection instead.

Fields§

§process: Child§stdout: ChildStdout§stdin: ChildStdin

Implementations§

source§

impl<MSend, MReceive> UciConnection<MSend, MReceive>
where MSend: Message, MReceive: Message,

source

pub fn new_from_path(path: &str) -> Result<Self, UciCreationError>

Creates a new UCI connection from the given executable path.

§Errors
  • Spawning the process errored.
  • Stdout is None.
  • Stdin is None.
source

pub fn send_message(&mut self, message: &MSend) -> Result<()>

Sends a message.

§Errors

See Write::write_all.

source

pub fn skip_lines(&mut self, count: usize) -> Result<()>

Skips some lines.

§Errors

See Read::read_exact.

source

pub fn read_message( &mut self ) -> Result<MReceive, UciReadMessageError<MReceive::ParameterPointer>>

Reads a line and attempts to parse it into a message.

§Errors
  • Reading resulted in an IO error.
  • Parsing the message errors.
source

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

Reads one line without the trailing '\n' character.

§Errors
  • Reading resulted in an IO error.
  • Parsing the message errors.
source§

impl UciConnection<GuiMessage, EngineMessage>

source

pub fn use_uci(&mut self) -> Result<(Option<IdMessageKind>, Vec<OptionMessage>)>

Sends the GuiMessage::UseUci message and returns the engine’s ID and a vector of options once the uciok message is received.

§Errors

See Write::write_all.

source

pub fn go( &mut self, message: GoMessage ) -> Result<(Vec<InfoMessage>, BestMoveMessage)>

Sends the go message to the engine and waits for the bestmove message response, returning it, along with a list of info messages.

See also the Self::go_async function, which can be interrupted.

§Errors
  • Writing (sending the message) errored.
  • Reading (reading back the responses) errored.
source

pub fn go_async( arc_self: Arc<Mutex<Self>>, message: GoMessage ) -> GuiToEngineUciConnectionGo<impl FnOnce() -> Result<(), GuiToEngineUciConnectionGoError>>

Sends the go message to the engine and waits for the bestmove message response, returning it. The info messages are sent through the returned receiver.

See also:

  • The Self::go function for a simpler alternative, but one that cannot be interrupted.
  • The go_stop example.
§Errors
  • Writing (sending the message) errored.
  • Reading (reading back the responses) errored.
source

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

Sends the isready message and waits for the readyok response.

§Errors
  • Writing (sending the message) errored.
  • Reading (reading until readyok) errored.

Trait Implementations§

source§

impl<MSend, MReceive> Debug for UciConnection<MSend, MReceive>
where MSend: Message + Debug, MReceive: Message + Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<MSend, MReceive> Freeze for UciConnection<MSend, MReceive>

§

impl<MSend, MReceive> RefUnwindSafe for UciConnection<MSend, MReceive>
where MSend: RefUnwindSafe, MReceive: RefUnwindSafe,

§

impl<MSend, MReceive> Send for UciConnection<MSend, MReceive>
where MSend: Send, MReceive: Send,

§

impl<MSend, MReceive> Sync for UciConnection<MSend, MReceive>
where MSend: Sync, MReceive: Sync,

§

impl<MSend, MReceive> Unpin for UciConnection<MSend, MReceive>
where MSend: Unpin, MReceive: Unpin,

§

impl<MSend, MReceive> UnwindSafe for UciConnection<MSend, MReceive>
where MSend: UnwindSafe, MReceive: UnwindSafe,

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>,

§

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>,

§

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.