Struct cw_controllers::Hooks

source ·
pub struct Hooks<'a>(_);

Implementations§

Examples found in repository?
src/hooks.rs (line 88)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
    pub fn execute_add_hook<C, Q: CustomQuery>(
        &self,
        admin: &Admin,
        deps: DepsMut<Q>,
        info: MessageInfo,
        addr: Addr,
    ) -> Result<Response<C>, HookError>
    where
        C: Clone + fmt::Debug + PartialEq + JsonSchema,
    {
        admin.assert_admin(deps.as_ref(), &info.sender)?;
        self.add_hook(deps.storage, addr.clone())?;

        let attributes = vec![
            attr("action", "add_hook"),
            attr("hook", addr),
            attr("sender", info.sender),
        ];
        Ok(Response::new().add_attributes(attributes))
    }
Examples found in repository?
src/hooks.rs (line 109)
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    pub fn execute_remove_hook<C, Q: CustomQuery>(
        &self,
        admin: &Admin,
        deps: DepsMut<Q>,
        info: MessageInfo,
        addr: Addr,
    ) -> Result<Response<C>, HookError>
    where
        C: Clone + fmt::Debug + PartialEq + JsonSchema,
    {
        admin.assert_admin(deps.as_ref(), &info.sender)?;
        self.remove_hook(deps.storage, addr.clone())?;

        let attributes = vec![
            attr("action", "remove_hook"),
            attr("hook", addr),
            attr("sender", info.sender),
        ];
        Ok(Response::new().add_attributes(attributes))
    }
Examples found in repository?
src/hooks.rs (line 127)
126
127
128
    pub fn query_hook<Q: CustomQuery>(&self, deps: Deps<Q>, hook: String) -> StdResult<bool> {
        Ok(self.query_hooks(deps)?.hooks.into_iter().any(|h| h == hook))
    }

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.