diff options
| author | mat <github@matdoes.dev> | 2022-10-23 22:59:38 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-10-23 22:59:38 -0500 |
| commit | 3869fd622f7515e934979478c439626981f0cd8a (patch) | |
| tree | 02861b45f20654aa086e7fb69ae54352b3f59810 /azalea-protocol/src/lib.rs | |
| parent | 65da123631b0a2dc078786f60fa6b213e8b430ee (diff) | |
| download | azalea-drasl-3869fd622f7515e934979478c439626981f0cd8a.tar.xz | |
write some more docs for az-protocol
Diffstat (limited to 'azalea-protocol/src/lib.rs')
| -rwxr-xr-x | azalea-protocol/src/lib.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs index 58ffac0a..ab447210 100755 --- a/azalea-protocol/src/lib.rs +++ b/azalea-protocol/src/lib.rs @@ -1,10 +1,13 @@ -//! This lib is responsible for parsing Minecraft packets. +//! A low-level crate to send and receive Minecraft packets. +//! +//! You should probably use [`azalea`] or [`azalea_client`] instead, as +//! azalea_protocol delegates much of the work, such as auth, to the user of +//! the crate. // these two are necessary for thiserror backtraces #![feature(error_generic_member_access)] #![feature(provide_any)] -use std::net::IpAddr; use std::str::FromStr; #[cfg(feature = "connecting")] @@ -15,18 +18,24 @@ pub mod read; pub mod resolver; pub mod write; +/// A host and port. It's possible that the port doesn't resolve to anything. +/// +/// # Examples +/// +/// ServerAddress implements TryFrom<&str>, so you can use it like this: +/// ``` +/// use azalea_protocol::ServerAddress; +/// +/// let addr = ServerAddress::try_from("localhost:25565").unwrap(); +/// assert_eq!(addr.host, "localhost"); +/// assert_eq!(addr.port, 25565); +/// ``` #[derive(Debug)] pub struct ServerAddress { pub host: String, pub port: u16, } -#[derive(Debug)] -pub struct ServerIpAddress { - pub ip: IpAddr, - pub port: u16, -} - // impl try_from for ServerAddress impl<'a> TryFrom<&'a str> for ServerAddress { type Error = String; |
