pub struct RconClient { /* private fields */ }
Expand description

Struct that stores the connection and other state of the RCON protocol with the server.

Examples

use mc_query::rcon::RconClient;
use tokio::io::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let mut client = RconClient::new("localhost", 25575).await?;
    client.authenticate("password").await?;

    let output = client.run_command("time set day").await?;
    println!("{output}");

    Ok(())
}

Implementations

Construct an RconClient that connects to the given host and port. Note: to authenticate use the authenticate method, this method does not take a password.

Arguments
  • host - A string slice that holds the hostname of the server to connect to.
  • port - The port to connect to.

Disconnect from the server and close the RCON connection.

Authenticate with the server, with the given password.

If authentication fails, this method will return RconProtocolError::AuthFailed.

Arguments
  • password - A string slice that holds the RCON password.

Run the given command on the server and return the result.

Arguments
  • command - A string slice that holds the command to run. Must be ASCII and under 1446 bytes in length.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.