Struct sentry_contrib_native::Dsn [−][src]
pub struct Dsn { /* fields omitted */ }
This is supported on crate feature
transport-custom
only.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
impl Dsn
[src]
pub fn new(dsn: &str) -> Result<Self, Error>
[src]
#[must_use]pub fn auth(&self) -> &str
[src]
#[must_use]
pub fn auth(&self) -> &strThe auth header value.
#[must_use]pub fn url(&self) -> &str
[src]
#[must_use]
pub fn url(&self) -> &strThe full URL to send envelopes to.
#[must_use]pub fn into_parts(self) -> Parts
[src]
#[must_use]
pub fn into_parts(self) -> PartsConsume Dsn
and return it’s parts.
#[must_use]pub fn to_headers(&self) -> HeaderMap
[src]
#[must_use]
pub fn to_headers(&self) -> HeaderMapTrait Implementations
impl Clone for Dsn
[src]
impl Debug for Dsn
[src]
impl Eq for Dsn
[src]
impl FromStr for Dsn
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Dsn
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Dsn
[src]
fn cmp(&self, other: &Dsn) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
pub fn max(self, other: Self) -> Self#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
pub fn min(self, other: Self) -> Self#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
#[must_use]
pub fn clamp(self, min: Self, max: Self) -> Selfimpl PartialEq<Dsn> for Dsn
[src]
impl PartialOrd<Dsn> for Dsn
[src]
fn partial_cmp(&self, other: &Dsn) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn lt(&self, other: &Rhs) -> bool#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn le(&self, other: &Rhs) -> bool#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn gt(&self, other: &Rhs) -> bool#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
pub fn ge(&self, other: &Rhs) -> boolimpl StructuralEq for Dsn
[src]
impl StructuralPartialEq for Dsn
[src]
impl TryFrom<&'_ str> for Dsn
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,