Struct RconClient

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

A client that has connected to an RCON server.

See the crate-level documentation for an example.

Implementations§

Source§

impl RconClient

Source

pub fn connect<A: ToSocketAddrs>(server_addr: A) -> Result<RconClient>

Construct a RconClient and connect to a server at the given address.

See the crate-level documentation for an example.

§Errors

This function errors if any I/O errors occur while setting up the connection. Most notably, if the server is not running or RCON is not enabled, this method will error with ConnectionRefused.

Source

pub fn is_logged_in(&self) -> bool

Returns whether this client is logged in.

Example:

let client = RconClient::connect("localhost:25575")?;
assert!(!client.is_logged_in());
client.log_in("SuperSecurePassword")?;
assert!(client.is_logged_in());
Source

pub fn log_in(&self, password: &str) -> Result<(), LogInError>

Attempts to log into the server with the given password.

See the crate-level documentation for an example.

§Errors
Source

pub fn send_command(&self, command: &str) -> Result<String, CommandError>

Sends the given command to the server and returns its response.

See the crate-level documentation for an example.

Valid commands are dependent on the server; documentation on the commands offered by vanilla Minecraft can be found at https://minecraft.wiki/w/Commands. Servers with mods or plugins may have other commands available.

The return value of this method is the response message from the server. This crate makes no attempt to interpret that response; in particular, this method will never error to indicate that the command failed: a successful return only means that the server recieved this command and responded to it.

§Errors

Trait Implementations§

Source§

impl Debug for RconClient

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.