pub struct DebugSubscriptionEvent {
pub data: DebugSubscriptionData,
}Expand description
A typed debug subscription event.
The wire representation is a VarInt DebugSubscriptionType followed by
the payload selected by that type. The discriminator is derived from
data, so an event cannot contain mismatched type and data.
§Examples
use mcproto_types::{
DebugSubscriptionData, DebugSubscriptionEvent, EntityBlockIntersectionDebugData,
EntityBlockIntersectionState, TypeCodec,
};
let event = DebugSubscriptionEvent::new(
DebugSubscriptionData::EntityBlockIntersection(
EntityBlockIntersectionDebugData {
state: EntityBlockIntersectionState::InFluid,
},
),
);
let mut encoded = Vec::new();
event.encode(&mut encoded)?;
assert_eq!(encoded, [0x06, 0x01]);
assert_eq!(DebugSubscriptionEvent::decode(&mut encoded.as_slice())?, event);See the official Debug Subscription Event documentation.
Fields§
§data: DebugSubscriptionDataPayload and its associated subscription type.
Implementations§
Source§impl DebugSubscriptionEvent
impl DebugSubscriptionEvent
Sourcepub const fn new(data: DebugSubscriptionData) -> Self
pub const fn new(data: DebugSubscriptionData) -> Self
Creates an event from a typed payload.
Sourcepub const fn subscription_type(&self) -> DebugSubscriptionType
pub const fn subscription_type(&self) -> DebugSubscriptionType
Returns the discriminator associated with this event.
Trait Implementations§
Source§impl Clone for DebugSubscriptionEvent
impl Clone for DebugSubscriptionEvent
Source§fn clone(&self) -> DebugSubscriptionEvent
fn clone(&self) -> DebugSubscriptionEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DebugSubscriptionEvent
impl Debug for DebugSubscriptionEvent
Source§impl From<DebugSubscriptionData> for DebugSubscriptionEvent
impl From<DebugSubscriptionData> for DebugSubscriptionEvent
Source§fn from(data: DebugSubscriptionData) -> Self
fn from(data: DebugSubscriptionData) -> Self
Converts to this type from the input type.
Source§impl PartialEq for DebugSubscriptionEvent
impl PartialEq for DebugSubscriptionEvent
impl StructuralPartialEq for DebugSubscriptionEvent
Auto Trait Implementations§
impl Freeze for DebugSubscriptionEvent
impl RefUnwindSafe for DebugSubscriptionEvent
impl Send for DebugSubscriptionEvent
impl Sync for DebugSubscriptionEvent
impl Unpin for DebugSubscriptionEvent
impl UnsafeUnpin for DebugSubscriptionEvent
impl UnwindSafe for DebugSubscriptionEvent
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ContextualCodec for Twhere
T: TypeCodec,
impl<T> ContextualCodec for Twhere
T: TypeCodec,
Source§fn encode_with_context(
&self,
writer: &mut impl Write,
_context: &Context,
) -> Result<(), CodecError>
fn encode_with_context( &self, writer: &mut impl Write, _context: &Context, ) -> Result<(), CodecError>
Encodes this value using context supplied by its enclosing structure.
Source§fn decode_with_context(
reader: &mut impl Read,
_context: &Context,
) -> Result<T, CodecError>where
T: Sized,
fn decode_with_context(
reader: &mut impl Read,
_context: &Context,
) -> Result<T, CodecError>where
T: Sized,
Decodes this value using context supplied by its enclosing structure.