Struct ruci::UciConnection
source · pub struct UciConnection<MSend, MReceive>{
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: ChildStdinImplementations§
source§impl<MSend, MReceive> UciConnection<MSend, MReceive>
impl<MSend, MReceive> UciConnection<MSend, MReceive>
sourcepub fn new_from_path(path: &str) -> Result<Self, UciCreationError>
pub fn new_from_path(path: &str) -> Result<Self, UciCreationError>
sourcepub fn send_message(&mut self, message: &MSend) -> Result<()>
pub fn send_message(&mut self, message: &MSend) -> Result<()>
sourcepub fn skip_lines(&mut self, count: usize) -> Result<()>
pub fn skip_lines(&mut self, count: usize) -> Result<()>
sourcepub fn read_message(
&mut self
) -> Result<MReceive, UciReadMessageError<MReceive::ParameterPointer>>
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§impl UciConnection<GuiMessage, EngineMessage>
impl UciConnection<GuiMessage, EngineMessage>
sourcepub fn use_uci(&mut self) -> Result<(Option<IdMessageKind>, Vec<OptionMessage>)>
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.
sourcepub fn go(
&mut self,
message: GoMessage
) -> Result<(Vec<InfoMessage>, BestMoveMessage)>
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.
sourcepub fn go_async(
arc_self: Arc<Mutex<Self>>,
message: GoMessage
) -> GuiToEngineUciConnectionGo<impl FnOnce() -> Result<(), GuiToEngineUciConnectionGoError>>
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::gofunction 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.
Trait Implementations§
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>
impl<MSend, MReceive> Sync for UciConnection<MSend, MReceive>
impl<MSend, MReceive> Unpin for UciConnection<MSend, MReceive>
impl<MSend, MReceive> UnwindSafe for UciConnection<MSend, MReceive>where
MSend: UnwindSafe,
MReceive: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more