pub struct Hook0Client { /* private fields */ }
Expand description
The Hook0 client
This struct is supposed to be initialized once and shared/reused wherever you need to send events in your app.
Implementations§
Source§impl Hook0Client
impl Hook0Client
Sourcepub fn new(
api_url: Url,
application_id: Uuid,
token: &str,
) -> Result<Self, Hook0ClientError>
pub fn new( api_url: Url, application_id: Uuid, token: &str, ) -> Result<Self, Hook0ClientError>
Initialize a client
api_url
- Base API URL of a Hook0 instance (example:https://app.hook0.com/api/v1
).application_id
- UUID of your Hook0 application.token
- Authentication token valid for your Hook0 application.
Sourcepub fn application_id(&self) -> &Uuid
pub fn application_id(&self) -> &Uuid
Get the application ID of this client
Sourcepub async fn send_event(
&self,
event: &Event<'_>,
) -> Result<Uuid, Hook0ClientError>
pub async fn send_event( &self, event: &Event<'_>, ) -> Result<Uuid, Hook0ClientError>
Send an event to Hook0
Sourcepub async fn upsert_event_types(
&self,
event_types: &[&str],
) -> Result<Vec<String>, Hook0ClientError>
pub async fn upsert_event_types( &self, event_types: &[&str], ) -> Result<Vec<String>, Hook0ClientError>
Ensure the configured app has the right event types or create them
Returns the list of event types that were created, if any.
Trait Implementations§
Source§impl Clone for Hook0Client
impl Clone for Hook0Client
Source§fn clone(&self) -> Hook0Client
fn clone(&self) -> Hook0Client
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for Hook0Client
impl !RefUnwindSafe for Hook0Client
impl Send for Hook0Client
impl Sync for Hook0Client
impl Unpin for Hook0Client
impl !UnwindSafe for Hook0Client
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