pub enum HashedSlot {
Empty,
Item(HashedItemStack),
}Expand description
An empty slot or an item stack represented using component data hashes.
A boolean is written first. false represents an empty slot. When it is
true, the item ID and count are followed by a prefixed array of component
type/hash pairs and a prefixed array of removed component types. Array order
is preserved exactly.
§Examples
use mcproto_types::{
DataComponentType, HashedDataComponent, HashedItemStack, HashedSlot, Int, TypeCodec,
};
let mut item = HashedItemStack::new(2, 5)?;
item.components_to_add.push(HashedDataComponent {
component_type: DataComponentType::MaxDamage,
data_hash: Int(0x1234_5678),
});
let slot = HashedSlot::Item(item);
let mut encoded = Vec::new();
slot.encode(&mut encoded)?;
let mut input = encoded.as_slice();
assert_eq!(HashedSlot::decode(&mut input)?, slot);See the official Hashed Format protocol documentation.
Variants§
Empty
Encoded only as a false presence boolean.
Item(HashedItemStack)
Encoded as true followed by the hashed item-stack fields.
Trait Implementations§
Source§impl Clone for HashedSlot
impl Clone for HashedSlot
Source§fn clone(&self) -> HashedSlot
fn clone(&self) -> HashedSlot
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 HashedSlot
impl Debug for HashedSlot
Source§impl Default for HashedSlot
impl Default for HashedSlot
Source§fn default() -> HashedSlot
fn default() -> HashedSlot
Returns the “default value” for a type. Read more
impl Eq for HashedSlot
Source§impl PartialEq for HashedSlot
impl PartialEq for HashedSlot
impl StructuralPartialEq for HashedSlot
Auto Trait Implementations§
impl Freeze for HashedSlot
impl RefUnwindSafe for HashedSlot
impl Send for HashedSlot
impl Sync for HashedSlot
impl Unpin for HashedSlot
impl UnsafeUnpin for HashedSlot
impl UnwindSafe for HashedSlot
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.