#[non_exhaustive]pub enum Frame {
Handshake {
protocol: VarInt,
address: String,
port: u16,
state: VarInt,
},
StatusRequest,
StatusResponse {
json: String,
},
PingRequest {
payload: i64,
},
PingResponse {
payload: i64,
},
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
Source§impl Frame
impl Frame
pub const PROTOCOL_VERSION: i32 = 767i32
pub const HANDSHAKE_ID: i32 = 0i32
pub const STATUS_REQUEST_ID: i32 = 0i32
pub const STATUS_RESPONSE_ID: i32 = 0i32
pub const PING_REQUEST_ID: i32 = 1i32
pub const PING_RESPONSE_ID: i32 = 1i32
Sourcepub fn check(buf: &mut Cursor<&[u8]>) -> Result<(), FrameError>
pub fn check(buf: &mut Cursor<&[u8]>) -> Result<(), FrameError>
Checks if an entire message can be decoded from buf, advancing the cursor past the header
Sourcepub fn parse(
cursor: &mut Cursor<&[u8]>,
server_state: Option<ServerState>,
) -> Result<Frame, FrameError>
pub fn parse( cursor: &mut Cursor<&[u8]>, server_state: Option<ServerState>, ) -> Result<Frame, FrameError>
Parse the body of a frame, after the message has already been validated with check.
§Arguments
src- The buffer containing the messageserver_state- Switches between which type of frame to accept. Set to None to accept frames for the client.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
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