Struct sentry_contrib_native::Dsn
source · [−]pub struct Dsn { /* private fields */ }
Expand description
Contains the pieces that are needed to build correct headers for a request based on the given DSN.
Examples
#![cfg(feature = "transport-custom")]
struct CustomTransport {
dsn: Dsn,
};
impl CustomTransport {
fn new(options: &Options) -> Result<Self, ()> {
Ok(CustomTransport {
// we can also get the DSN here
dsn: options.dsn().and_then(|dsn| Dsn::new(dsn).ok()).ok_or(())?,
})
}
}
impl Transport for CustomTransport {
fn send(&self, envelope: RawEnvelope) {
// we need `Dsn` to build the `Request`!
envelope.to_request(self.dsn.clone());
// or build your own request with the help of a URL, `HeaderMap` and body.
let (url, headers, body): (&str, HeaderMap, &[u8]) = (self.dsn.url(), self.dsn.to_headers(), envelope.serialize().as_bytes());
}
}
let dsn = "https://public_key_1234@organization_1234.ingest.sentry.io/project_id_1234";
let mut options = Options::new();
options.set_dsn(dsn);
// we can take the `dsn` right here
let custom_transport = CustomTransport {
dsn: Dsn::new(dsn)?,
};
options.set_transport(move |_| Ok(custom_transport));
// this is also possible
options.set_transport(|options| Ok(CustomTransport {
dsn: options.dsn().and_then(|dsn| Dsn::new(dsn).ok()).ok_or(())?,
}));
// or use a method more directly
options.set_transport(CustomTransport::new);
Implementations
Trait Implementations
sourceimpl Ord for Dsn
impl Ord for Dsn
sourceimpl PartialOrd<Dsn> for Dsn
impl PartialOrd<Dsn> for Dsn
sourcefn partial_cmp(&self, other: &Dsn) -> Option<Ordering>
fn partial_cmp(&self, other: &Dsn) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Dsn
impl StructuralEq for Dsn
impl StructuralPartialEq for Dsn
Auto Trait Implementations
impl RefUnwindSafe for Dsn
impl Send for Dsn
impl Sync for Dsn
impl Unpin for Dsn
impl UnwindSafe for Dsn
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more