pub struct Builder<T> { /* private fields */ }
Implementations§
Source§impl Builder<AsyncStdStream>
impl Builder<AsyncStdStream>
Sourcepub async fn connect<A: ToSocketAddrs>(
self,
address: A,
password: &str,
) -> Result<Connection<AsyncStdStream>>
Available on crate feature rt-async-std
only.
pub async fn connect<A: ToSocketAddrs>( self, address: A, password: &str, ) -> Result<Connection<AsyncStdStream>>
rt-async-std
only.Connect to an rcon server using the async-std runtime.
Source§impl Builder<TcpStream>
impl Builder<TcpStream>
Sourcepub async fn connect<A: ToSocketAddrs>(
self,
address: A,
password: &str,
) -> Result<Connection<TcpStream>>
Available on crate feature rt-tokio
only.
pub async fn connect<A: ToSocketAddrs>( self, address: A, password: &str, ) -> Result<Connection<TcpStream>>
rt-tokio
only.Connect to an rcon server using the Tokio runtime.
Source§impl<T> Builder<T>
impl<T> Builder<T>
pub fn new() -> Self
Sourcepub fn enable_minecraft_quirks(self, value: bool) -> Self
pub fn enable_minecraft_quirks(self, value: bool) -> Self
This enables the following quirks for Minecraft:
Commands are delayed by 3ms to reduce the chance of crashing the server. See https://bugs.mojang.com/browse/MC-72390.
The command length is limited to 1413 bytes. Tests have shown the server to not work reliably with greater command lengths.
Sourcepub fn enable_factorio_quirks(self, value: bool) -> Self
pub fn enable_factorio_quirks(self, value: bool) -> Self
This enables the following quirks for Factorio:
Only single-packet responses are enabled. Multi-packets appear to work differently than in other server implementations (an empty packet gives no response).
Sourcepub fn sleep_fn<F, Fut>(self, f: F) -> Self
pub fn sleep_fn<F, Fut>(self, f: F) -> Self
Set a custom function to use for sleeping between requests when Minecraft quirks mode is enabled.
When either of the rt-tokio
or rt-async-std
feature flags is enabled, this library will
default to using the runtime’s native sleeping function. This can be used to override it,
or set the sleeping function to use when no runtime feature is active.
§Example
Using futures-timer instead of Tokio’s native timer:
let connection = <rcon::Connection<TcpStream>>::builder()
.enable_minecraft_quirks(true)
.sleep_fn(futures_timer::Delay::new)
.connect("localhost:25575", "hunter2")
.await?;
Sourcepub async fn handshake(self, io: T, password: &str) -> Result<Connection<T>>
pub async fn handshake(self, io: T, password: &str) -> Result<Connection<T>>
Perform a handshake on an existing connection to an rcon server.
This is a lower-level method mostly useful when integrating this crate with another
runtime, or running rcon over a transport other than TCP. You generally will want to use
one of the higher-level connect
methods.
§Panics
If neither of the rt-tokio
or rt-async-std
feature flags are activated, no custom sleep
function has been set and Minecraft quirks
have been enabled, this function will panic as Minecraft quirks need some way to
asynchronously sleep.