diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/examples/schedule_task.rs | 2 | ||||
-rw-r--r-- | core/extensions.rs | 11 | ||||
-rw-r--r-- | core/runtime.rs | 6 |
3 files changed, 7 insertions, 12 deletions
diff --git a/core/examples/schedule_task.rs b/core/examples/schedule_task.rs index 56c8f6dd6..42d00022d 100644 --- a/core/examples/schedule_task.rs +++ b/core/examples/schedule_task.rs @@ -34,8 +34,6 @@ fn main() { let (tx, rx) = mpsc::unbounded::<Task>(); state.put(tx); state.put(rx); - - Ok(()) }) .build(); diff --git a/core/extensions.rs b/core/extensions.rs index ead1fa354..beddce4c7 100644 --- a/core/extensions.rs +++ b/core/extensions.rs @@ -42,7 +42,7 @@ pub struct ExtensionFileSource { } pub type OpFnRef = v8::FunctionCallback; pub type OpMiddlewareFn = dyn Fn(OpDecl) -> OpDecl; -pub type OpStateFn = dyn Fn(&mut OpState) -> Result<(), Error>; +pub type OpStateFn = dyn Fn(&mut OpState); pub type OpEventLoopFn = dyn Fn(Rc<RefCell<OpState>>, &mut Context) -> bool; pub struct OpDecl { @@ -147,10 +147,9 @@ impl Extension { } /// Allows setting up the initial op-state of an isolate at startup. - pub fn init_state(&self, state: &mut OpState) -> Result<(), Error> { - match &self.opstate_fn { - Some(ofn) => ofn(state), - None => Ok(()), + pub fn init_state(&self, state: &mut OpState) { + if let Some(op_fn) = &self.opstate_fn { + op_fn(state); } } @@ -243,7 +242,7 @@ impl ExtensionBuilder { pub fn state<F>(&mut self, opstate_fn: F) -> &mut Self where - F: Fn(&mut OpState) -> Result<(), Error> + 'static, + F: Fn(&mut OpState) + 'static, { self.state = Some(Box::new(opstate_fn)); self diff --git a/core/runtime.rs b/core/runtime.rs index 1d74c9ede..92e23873a 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -939,7 +939,7 @@ impl JsRuntime { // Setup state for e in extensions.iter_mut() { // ops are already registered during in bindings::initialize_context(); - e.init_state(&mut op_state.borrow_mut())?; + e.init_state(&mut op_state.borrow_mut()); // Setup event-loop middleware if let Some(middleware) = e.init_event_loop_middleware() { @@ -957,7 +957,7 @@ impl JsRuntime { // Setup state for e in extensions.iter_mut() { // ops are already registered during in bindings::initialize_context(); - e.init_state(&mut op_state.borrow_mut())?; + e.init_state(&mut op_state.borrow_mut()); // Setup event-loop middleware if let Some(middleware) = e.init_event_loop_middleware() { @@ -2887,7 +2887,6 @@ pub mod tests { mode, dispatch_count: dispatch_count2.clone(), }); - Ok(()) }) .build(); let mut runtime = JsRuntime::new(RuntimeOptions { @@ -4045,7 +4044,6 @@ assertEquals(1, notify_return_value); .ops(vec![op_async_borrow::decl()]) .state(|state| { state.put(InnerState(42)); - Ok(()) }) .build(); |