aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'minecraft-protocol/src/lib.rs')
-rw-r--r--minecraft-protocol/src/lib.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/minecraft-protocol/src/lib.rs b/minecraft-protocol/src/lib.rs
index 5d6c8330..31b50164 100644
--- a/minecraft-protocol/src/lib.rs
+++ b/minecraft-protocol/src/lib.rs
@@ -3,7 +3,7 @@
use std::net::IpAddr;
use std::str::FromStr;
-pub mod connection;
+pub mod connect;
pub mod mc_buf;
pub mod packets;
pub mod resolver;
@@ -20,9 +20,12 @@ pub struct ServerIpAddress {
pub port: u16,
}
-impl ServerAddress {
+// impl try_from for ServerAddress
+impl<'a> TryFrom<&'a str> for ServerAddress {
+ type Error = String;
+
/// Convert a Minecraft server address (host:port, the port is optional) to a ServerAddress
- pub fn parse(string: &str) -> Result<ServerAddress, String> {
+ fn try_from(string: &str) -> Result<Self, Self::Error> {
if string.is_empty() {
return Err("Empty string".to_string());
}