# actix_web::actix::actix::msgs::Execute - Rust
API documentation for the Rust `Execute` struct in crate `actix_web`.
Keywords: rust, rustlang, rust-lang, Execute

# Struct actix_web::actix::actix::msgs::Execute [−]

    pub struct Execute<I = (), E = ()>(_)
     where
        E: 'static + Send,
        I: 'static + Send;

Execute function in arbiter's thread

Arbiter` actor handles Execute message.

# Example

    use actix::prelude::*;

    struct MyActor {
        addr: Addr<Arbiter>,
    }

    impl Actor for MyActor {
        type Context = Context<Self>;

        fn started(&mut self, ctx: &mut Context<Self>) {
            self.addr
                .do_send(actix::msgs::Execute::new(|| -> Result<(), ()> {
                    // do something
                    // ...
                    Ok(())
                }));
        }
    }
    fn main() {}

## Methods

###

`impl<I, E> Execute<I, E> where E: Send + 'static, I: Send + 'static,`

####

`pub fn new<F>(f: F) -> Execute<I, E> where F: FnOnce() -> Result<I, E> + Send + 'static,` |

####

`pub fn exec(self) -> Result<I, E>` |

Execute enclosed function

## Trait Implementations

###

`impl<I, E> Message for Execute<I, E> where E: Send, I: Send,`

Execute message response

#### `type Result = Result<I, E>`

The type of value that this message will resolved with if it is successful. Read more

###

`impl<I, E> Handler<Execute<I, E>> for Arbiter where E: Send, I: Send,`

#### `type Result = Result<I, E>`

The type of value that this handle will return

####

`fn handle(&mut self, msg: Execute<I, E>, &mut Context<Arbiter>) -> Result<I, E>` |

Method is called for every message received by this Actor

## Auto Trait Implementations

###

`impl<I, E> Send for Execute<I, E>`

###

`impl<I = (), E = ()> !Sync for Execute<I, E>`

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)