qubit-event-bus 0.6.3

A lightweight, thread-safe in-process event bus for Rust
Documentation
/*******************************************************************************
 *
 *    Copyright (c) 2026 Haixing Hu.
 *
 *    SPDX-License-Identifier: Apache-2.0
 *
 *    Licensed under the Apache License, Version 2.0.
 *
 ******************************************************************************/
//! Conversion trait for handler return values.

use crate::EventBusResult;

/// Converts closure return values into [`EventBusResult<()>`].
///
/// This trait lets event handlers and error handlers return either `()` for a
/// successful outcome or [`EventBusResult<()>`] when they need to report a
/// failure.
pub trait IntoEventBusResult {
    /// Converts the value into an event bus result.
    ///
    /// # Returns
    /// `Ok(())` for successful handler results, or the original error.
    fn into_event_bus_result(self) -> EventBusResult<()>;
}

impl IntoEventBusResult for () {
    /// Converts a unit return value into success.
    fn into_event_bus_result(self) -> EventBusResult<()> {
        Ok(())
    }
}

impl IntoEventBusResult for EventBusResult<()> {
    /// Returns the original event bus result.
    fn into_event_bus_result(self) -> EventBusResult<()> {
        self
    }
}