sentry_types/
lib.rs

1//! This crate provides common types for working with the Sentry protocol or the
2//! Sentry server.  It's used by the Sentry Relay infrastructure as well as the
3//! rust Sentry client.
4//!
5//! Most of the types in this crate are serializable in one form or another.
6//! The types in the `protocol` module are generally really only serializable
7//! to JSON as other formats are not supported by Sentry at this date.
8//!
9//! ## Contents
10//!
11//! The crate provides a bunch of common types for working with Sentry as
12//! such (DSN, ProjectIDs, authentication headers) as well as types for
13//! the Sentry event protocol.
14//!
15//! Right now only `v7` of the protocol is implemented but it's versioned
16//! so later versions might be added later.
17//!
18//! ## API Concepts
19//!
20//! Most types are directly serializable or deserializable and try to implement
21//! the `Default` type.  This means that objects can be created conveniently
22//! and missing attributes can be filled in:
23//!
24//! ```rust
25//! use sentry_types::protocol::v7;
26//!
27//! let event = v7::Event {
28//!     message: Some("Hello World!".to_string()),
29//!     culprit: Some("foo in bar".to_string()),
30//!     level: v7::Level::Info,
31//!     ..Default::default()
32//! };
33//! ```
34
35#![doc(html_favicon_url = "https://sentry-brand.storage.googleapis.com/favicon.ico")]
36#![doc(html_logo_url = "https://sentry-brand.storage.googleapis.com/sentry-glyph-black.png")]
37#![warn(missing_docs)]
38
39#[macro_use]
40mod macros;
41
42mod auth;
43mod crontab_validator;
44mod dsn;
45mod project_id;
46pub mod protocol;
47pub(crate) mod utils;
48
49pub use crate::auth::*;
50pub use crate::dsn::*;
51pub use crate::project_id::*;
52
53// Re-export external types and traits for convenience
54pub use debugid::*;
55pub use uuid::{Uuid, Variant as UuidVariant, Version as UuidVersion};
56
57/// Generates a random [Uuid] using a thread local RNG.
58pub fn random_uuid() -> Uuid {
59    uuid::Builder::from_random_bytes(rand::random()).into_uuid()
60}