pub enum DebugSubscriptionUpdate {
Absent(DebugSubscriptionType),
Present(DebugSubscriptionData),
}Expand description
A debug subscription type followed by prefixed optional matching data.
Absent writes the type and a false boolean. A
Present value writes the payload’s type, a true boolean,
and the matching payload. This representation cannot pair one subscription
type with another type’s data.
§Examples
use mcproto_types::{
DebugSubscriptionData, DebugSubscriptionType, DebugSubscriptionUpdate, TypeCodec,
};
let absent = DebugSubscriptionUpdate::absent(DebugSubscriptionType::Bee);
let mut encoded = Vec::new();
absent.encode(&mut encoded)?;
assert_eq!(encoded, [0x01, 0x00]);
assert_eq!(DebugSubscriptionUpdate::decode(&mut encoded.as_slice())?, absent);
let present = DebugSubscriptionUpdate::present(
DebugSubscriptionData::DedicatedServerTickTime,
);
let mut encoded = Vec::new();
present.encode(&mut encoded)?;
assert_eq!(encoded, [0x00, 0x01]);See the official Debug Subscription Update documentation.
Variants§
Absent(DebugSubscriptionType)
The selected subscription type has no following payload.
Present(DebugSubscriptionData)
The selected subscription type is followed by its payload.
Implementations§
Source§impl DebugSubscriptionUpdate
impl DebugSubscriptionUpdate
Sourcepub const fn absent(subscription_type: DebugSubscriptionType) -> Self
pub const fn absent(subscription_type: DebugSubscriptionType) -> Self
Creates an update with no payload.
Sourcepub const fn present(data: DebugSubscriptionData) -> Self
pub const fn present(data: DebugSubscriptionData) -> Self
Creates an update containing matching typed data.
Sourcepub const fn subscription_type(&self) -> DebugSubscriptionType
pub const fn subscription_type(&self) -> DebugSubscriptionType
Returns the selected subscription type.
Sourcepub const fn data(&self) -> Option<&DebugSubscriptionData>
pub const fn data(&self) -> Option<&DebugSubscriptionData>
Returns the payload when present.
Sourcepub const fn is_present(&self) -> bool
pub const fn is_present(&self) -> bool
Returns whether this update contains a payload.
Trait Implementations§
Source§impl Clone for DebugSubscriptionUpdate
impl Clone for DebugSubscriptionUpdate
Source§fn clone(&self) -> DebugSubscriptionUpdate
fn clone(&self) -> DebugSubscriptionUpdate
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 DebugSubscriptionUpdate
impl Debug for DebugSubscriptionUpdate
Source§impl PartialEq for DebugSubscriptionUpdate
impl PartialEq for DebugSubscriptionUpdate
impl StructuralPartialEq for DebugSubscriptionUpdate
Auto Trait Implementations§
impl Freeze for DebugSubscriptionUpdate
impl RefUnwindSafe for DebugSubscriptionUpdate
impl Send for DebugSubscriptionUpdate
impl Sync for DebugSubscriptionUpdate
impl Unpin for DebugSubscriptionUpdate
impl UnsafeUnpin for DebugSubscriptionUpdate
impl UnwindSafe for DebugSubscriptionUpdate
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.