pub struct GameRule<T: GameRuleValueType> {
key: Identifier,
category: GameRuleCategory,
value_type: GameRuleType,
default_value: T,
min_value: Option<i32>,
max_value: Option<i32>,
codec: GameRuleCodec<T>,
}Expand description
A typed game rule definition.
Fields§
§key: Identifier§category: GameRuleCategory§value_type: GameRuleType§default_value: T§min_value: Option<i32>§max_value: Option<i32>§codec: GameRuleCodec<T>Implementations§
Source§impl<T: GameRuleValueType> GameRule<T>
impl<T: GameRuleValueType> GameRule<T>
pub const fn key(&self) -> &Identifier
pub const fn category(&self) -> GameRuleCategory
pub const fn value_type(&self) -> GameRuleType
pub const fn default_value(&self) -> &T
pub const fn min_value(&self) -> Option<i32>
pub const fn max_value(&self) -> Option<i32>
fn validates(&self, value: &T) -> bool
Source§impl GameRule<bool>
impl GameRule<bool>
pub const fn boolean( key: Identifier, category: GameRuleCategory, default_value: bool, ) -> Self
Trait Implementations§
impl<T: GameRuleValueType> Eq for GameRule<T>
Source§impl<T: GameRuleValueType> ErasedGameRule for GameRule<T>
impl<T: GameRuleValueType> ErasedGameRule for GameRule<T>
fn key(&self) -> &Identifier
fn category(&self) -> GameRuleCategory
fn value_type(&self) -> GameRuleType
fn min_value(&self) -> Option<i32>
fn max_value(&self) -> Option<i32>
fn default_erased_value(&self) -> GameRuleValue
fn validates_erased_value(&self, value: &GameRuleValue) -> bool
fn serialize_erased_value(&self, value: &GameRuleValue) -> Value
fn deserialize_erased_value(&self, value: &Value) -> Option<GameRuleValue>
fn erased_command_result(&self, value: &GameRuleValue) -> i32
Auto Trait Implementations§
impl<T> Freeze for GameRule<T>where
T: Freeze,
impl<T> RefUnwindSafe for GameRule<T>where
T: RefUnwindSafe,
impl<T> Send for GameRule<T>
impl<T> Sync for GameRule<T>
impl<T> Unpin for GameRule<T>where
T: Unpin,
impl<T> UnsafeUnpin for GameRule<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for GameRule<T>where
T: UnwindSafe,
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>