pub struct ClientHandshake {
pub len: VarInt,
pub packet_id: VarInt,
pub protocol_version: VarInt,
pub server_addr: String,
pub server_port: u16,
pub next_state: VarInt,
}Expand description
Represents the Minecraft client handshake packet.
This packet initiates the handshake with the server before status or login requests.
§Example
let handshake = ClientHandshake::new("127.0.0.1".to_string(), 25565);
let bytes = handshake.to_bytes();Fields§
§len: VarIntLength of the entire packet, encoded as a VarInt.
packet_id: VarIntPacket ID (0x00 for handshake).
protocol_version: VarIntProtocol version number, e.g., 768 for Minecraft 1.21.
server_addr: StringServer address as a string (domain or IP).
server_port: u16Server port number.
next_state: VarIntNext state after handshake: 1 = status, 2 = login.
Implementations§
Source§impl ClientHandshake
impl ClientHandshake
Sourcepub fn new(server_addr: String, server_port: u16) -> ClientHandshake
pub fn new(server_addr: String, server_port: u16) -> ClientHandshake
Creates a new ClientHandshake packet for the given server address and port.
Automatically calculates packet length and uses default protocol version 768.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClientHandshake
impl RefUnwindSafe for ClientHandshake
impl Send for ClientHandshake
impl Sync for ClientHandshake
impl Unpin for ClientHandshake
impl UnsafeUnpin for ClientHandshake
impl UnwindSafe for ClientHandshake
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more