pub unsafe trait HasId: RoomObjectProperties {
    fn untyped_id(&self) -> RawObjectId { ... }
    fn id(&self) -> ObjectId<Self>
   where
        Self: Sized
, { ... } }
Expand description

Trait covering all objects with an id.

Provided Methods

Retrieves this object’s id as an untyped, packed value.

This has no major differences from HasId::id except for the return value not being typed by the kind of thing it points to. As the type of an ObjectId can be freely changed, that isn’t a big deal.

Retrieves this object’s id as a typed, packed value.

This can be helpful for use with game::get_object_typed, as it will force rust to infer the proper return type.

If an ID without these protections is needed, use HasId::untyped_id, or RawObjectId::from(x.id()).

Note that the ID returned is also stored as a packed, 12-byte value on the stack, so it’s fairly efficient to move and copy around.

Implementors