pub struct RconClient { /* private fields */ }Expand description
Async RCON client for Factorio
Implementations§
Source§impl RconClient
impl RconClient
Sourcepub async fn connect(addr: impl AsRef<str>, password: &str) -> Result<Self>
pub async fn connect(addr: impl AsRef<str>, password: &str) -> Result<Self>
Connect to an RCON server and authenticate
Uses the default 5-second timeout for both TCP connection and auth.
§Arguments
addr- Server address (e.g., “127.0.0.1:27015”)password- RCON password
§Example
use factorio_rcon::RconClient;
let mut client = RconClient::connect("127.0.0.1:27015", "password").await?;Sourcepub async fn execute_with_timeout(
&mut self,
command: &str,
timeout_duration: Duration,
) -> Result<String>
pub async fn execute_with_timeout( &mut self, command: &str, timeout_duration: Duration, ) -> Result<String>
Execute a command with a custom timeout
The timeout covers the entire round-trip (send + receive).
§Arguments
command- Command to executetimeout_duration- Maximum time to wait for the complete operation
§Example
let result = client.execute_with_timeout(
"/c rcon.print(serpent.line(game.surfaces))",
Duration::from_secs(10)
).await?;Sourcepub fn set_timeout(&mut self, duration: Duration)
pub fn set_timeout(&mut self, duration: Duration)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RconClient
impl RefUnwindSafe for RconClient
impl Send for RconClient
impl Sync for RconClient
impl Unpin for RconClient
impl UnwindSafe for RconClient
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