lemon_bugsnag_rs 0.1.2

A library for interacting with the BugSnag error-reporting and sessions APIs.
Documentation
/// Trait to be implemented for synchronous backend clients. For example, a
/// client built using [ureq::Request](https://docs.rs/ureq/2.12.1/ureq/struct.Request.html) as the backend. See
/// [UreqErrorSync](crate::error::ureq::client::blocking::UreqErrorSync).
/// See [Implementors](ClientTraitSync#implementors)
///
/// # Example
/// ```
/// use lemon_bugsnag_rs::common::traits::client_trait_sync::ClientTraitSync;
/// use lemon_bugsnag_rs::common::error::Error;
///
/// struct MySyncClient {}
/// struct MySyncResponse {}
///
/// impl ClientTraitSync for MySyncClient {
///     type Response = MySyncResponse;
///     type Error = Error;
///
///     fn send(&mut self) -> Result<Self::Response, Self::Error> {
///         // For purposes of this example, BackendClient::send() is a
///         // function that returns Result<MySyncResponse, BackendError>,
///         // where From<BackendError> has been implemented for Self::Error.
///         # #[cfg(norun)]
///         let result = BackendClient::send();
///         # let result: Result<Self::Response, Self::Error> = Ok(MySyncResponse {});
///         Ok(result?)
///     }
/// }
/// ```
pub trait ClientTraitSync {
    /// The response type returned by the backend client.
    ///
    /// ```
    /// // This example requires the sync feature.
    /// // This example requires the ureq feature.
    ///
    /// use lemon_bugsnag_rs::common::traits::client_trait_sync::ClientTraitSync;
    /// use ureq::Response;
    ///
    /// struct MyClient {}
    /// # #[cfg(feature = "ureq")]
    /// # {
    /// # #[cfg(norun)]
    /// impl ClientTraitAsync for MyClient {
    ///     type Response = Response;
    /// #    type Error = lemon_bugsnag_rs::common::error::Error;
    ///
    ///     // ... implement send()
    /// }
    /// # }
    /// ```
    type Response;
    /// The error type to be returned from the `send()` function. In almost all
    /// cases, this should be [crate::common::error::Error], where
    /// `common::error::Error` implements `From<>` for the error type returned
    /// by your networking library. This ensures a consistent
    /// experience for users of `lemon-bugsnag-rs`. See the `From<>`
    /// implementations in [Error](crate::common::error::Error#trait-implementations)
    /// for examples of this being done with the Ureq and Reqwest networking
    /// libraries.
    ///
    /// ```
    /// // This example requires the sync feature.
    /// // This example requires the ureq feature.
    ///
    /// use lemon_bugsnag_rs::common::traits::client_trait_sync::ClientTraitSync;
    /// use ureq::Response;
    ///
    /// struct MyClient {}
    /// # #[cfg(feature = "ureq")]
    /// # {
    /// # #[cfg(norun)]
    /// impl ClientTraitSync for MyClient {
    /// #    type Response = Response;
    ///     type Error = lemon_bugsnag_rs::common::error::Error;
    ///
    ///     // ... implement send()
    /// }
    /// # }
    /// ```
    type Error: std::error::Error;

    /// Send the client's payload.
    /// ```
    /// // This test requires the sync feature.
    /// // This test requires the reqwest feature.
    /// // This test requires the error-client feature.
    ///
    /// use lemon_bugsnag_rs::common::{
    ///     builder::client_builder::ClientBuilder,
    ///     traits::{
    ///         backend_builder_trait_sync::BackendBuilderTraitSync,
    ///         decider_trait_sync::DeciderTraitSync,
    ///         client_trait_sync::ClientTraitSync
    ///     },
    /// };
    ///
    /// let mut cb = ClientBuilder::error();
    ///
    /// # #[cfg(norun)]
    /// cb.configure(
    ///     std::env::var("NAB_BUGSNAG_RS_API_KEY").unwrap().as_str(),
    ///     "NAB BugSnag RS Doctest Error Class",
    ///     "Some generic error message",
    ///     "NAB BugSnag RS Doctest Notifier",
    ///     "0.0.2",
    ///     "Fake App Stage",
    ///     "Fake Release Stage",
    /// );
    ///
    /// # cb.configure(
    /// #   "fake API key",
    /// #   "NAB BugSnag RS Doctest Error Class",
    /// #   "Some generic error message",
    /// #   "NAB BugSnag RS Doctest Notifier",
    /// #   "0.0.2",
    /// #   "Fake App Stage",
    /// #   "Fake Release Stage",
    /// # );
    ///
    ///
    /// let result = cb.reqwest().blocking().build().unwrap().send();
    ///
    /// // Handle your result
    /// // ...
    /// ```
    fn send(&mut self) -> Result<Self::Response, Self::Error>;
}