Enum cw_clearable::Clearable
source · pub enum Clearable<C> {
Clear,
Set(C),
}
Expand description
A type representing a value that can either be cleared or set with a value of type C
.
use cosmwasm_std::{StdResult, Response, DepsMut};
use cw_storage_plus::Item;
use cw_clearable::Clearable;
const FOO: Item<Option<u32>> = Item::new("foo");
pub fn update_config(deps: DepsMut, foo: Option<Clearable<u32>>) -> StdResult<Response>{
if let Some(foo) = foo {
FOO.save(deps.storage, &foo.into());
}
Ok(Response::new())
}
Variants§
Implementations§
Trait Implementations§
source§impl<'de, C> Deserialize<'de> for Clearable<C>where
C: Deserialize<'de>,
impl<'de, C> Deserialize<'de> for Clearable<C>where
C: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<C: JsonSchema> JsonSchema for Clearable<C>
impl<C: JsonSchema> JsonSchema for Clearable<C>
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl<C: PartialEq> PartialEq for Clearable<C>
impl<C: PartialEq> PartialEq for Clearable<C>
impl<C> StructuralPartialEq for Clearable<C>
Auto Trait Implementations§
impl<C> RefUnwindSafe for Clearable<C>where
C: RefUnwindSafe,
impl<C> Send for Clearable<C>where
C: Send,
impl<C> Sync for Clearable<C>where
C: Sync,
impl<C> Unpin for Clearable<C>where
C: Unpin,
impl<C> UnwindSafe for Clearable<C>where
C: UnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read moresource§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