pub struct WebhookHandler { /* private fields */ }
Implementations§
Source§impl WebhookHandler
impl WebhookHandler
Sourcepub fn new(target_config: Target, client: Client) -> Self
pub fn new(target_config: Target, client: Client) -> Self
Creates a new WebhookHandler given a target configuration and a reqwest client.
§Arguments
target_config
- The target configuration.client
- The reqwest client to use for requests.
§Examples
use pixy_core::config::{Target, TargetProperties::Webhook, WebhookTargetProperties};
use pixy_core::handlers::WebhookHandler;
let target = Target {
name: "test".to_string(),
enabled: true,
properties: Webhook(WebhookTargetProperties {
url: "https://example.com".to_string(),
retries: 3,
timeout: 5,
auth: None,
}),
};
let client = reqwest::Client::new();
let handler = WebhookHandler::new(target, client);
Trait Implementations§
Source§impl Debug for WebhookHandler
impl Debug for WebhookHandler
Source§impl From<Target> for WebhookHandler
impl From<Target> for WebhookHandler
Source§fn from(target_config: Target) -> Self
fn from(target_config: Target) -> Self
Creates a new WebhookHandler given a target configuration.
§Arguments
target_config
- The target configuration.
§Examples
use pixy_core::config::{Target, TargetProperties::Webhook, WebhookTargetProperties};
use pixy_core::handlers::WebhookHandler;
let target = Target {
name: "test".to_string(),
enabled: true,
properties: Webhook(WebhookTargetProperties {
url: "https://example.com".to_string(),
retries: 3,
timeout: 5,
auth: None,
}),
};
let handler = WebhookHandler::from(target);
Source§impl SensorHandler for WebhookHandler
impl SensorHandler for WebhookHandler
Source§fn handle_reading<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
reading: &'life1 SensorMessage,
context: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_reading<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
reading: &'life1 SensorMessage,
context: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Publishes the given reading to the target.
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Returns whether or not the handler is enabled.
Auto Trait Implementations§
impl Freeze for WebhookHandler
impl !RefUnwindSafe for WebhookHandler
impl Send for WebhookHandler
impl Sync for WebhookHandler
impl Unpin for WebhookHandler
impl !UnwindSafe for WebhookHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more