Skip to content

Commit 0ae2eb1

Browse files
committed
feat: Added missing basic docs to attributes
1 parent 63e7ed8 commit 0ae2eb1

File tree

1 file changed

+111
-29
lines changed

1 file changed

+111
-29
lines changed

src/protocol/v7.rs

Lines changed: 111 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ pub struct Stacktrace {
139139
/// Represents a thread id.
140140
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
141141
pub enum ThreadId {
142+
/// Integer representation for the thread id
142143
Int(i64),
144+
/// String representation for the thread id
143145
String(String),
144146
}
145147

@@ -162,10 +164,17 @@ impl fmt::Display for ThreadId {
162164
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
163165
#[serde(default)]
164166
pub struct Thread {
167+
/// The optional ID of the thread (usually an integer)
165168
pub id: Option<ThreadId>,
169+
/// The optional name of the thread.
166170
pub name: Option<String>,
171+
/// If the thread suspended or crashed a stacktrace can be
172+
/// attached here.
167173
pub stacktrace: Option<Stacktrace>,
174+
/// indicates a crashed thread
168175
pub crashed: bool,
176+
/// indicates that the thread was not suspended when the
177+
/// event was created.
169178
pub current: bool,
170179
}
171180

@@ -236,12 +245,25 @@ impl Level {
236245
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
237246
#[serde(default)]
238247
pub struct Breadcrumb {
239-
#[serde(with = "chrono::serde::ts_seconds")] pub timestamp: DateTime<Utc>,
240-
#[serde(rename = "type")] pub ty: String,
241-
#[serde(skip_serializing_if = "Option::is_none")] pub category: Option<String>,
242-
#[serde(skip_serializing_if = "Level::is_info")] pub level: Level,
243-
#[serde(skip_serializing_if = "Option::is_none")] pub message: Option<String>,
244-
#[serde(skip_serializing_if = "HashMap::is_empty")] pub data: HashMap<String, Value>,
248+
/// The timestamp of the breadcrumb. This is required.
249+
#[serde(with = "chrono::serde::ts_seconds")]
250+
pub timestamp: DateTime<Utc>,
251+
/// The type of the breadcrumb.
252+
#[serde(rename = "type")]
253+
pub ty: String,
254+
/// The optional category of the breadcrumb.
255+
#[serde(skip_serializing_if = "Option::is_none")]
256+
pub category: Option<String>,
257+
/// The non optional level of the breadcrumb. It
258+
/// defaults to info.
259+
#[serde(skip_serializing_if = "Level::is_info")]
260+
pub level: Level,
261+
/// An optional human readbale message for the breadcrumb.
262+
#[serde(skip_serializing_if = "Option::is_none")]
263+
pub message: Option<String>,
264+
/// Arbitrary breadcrumb data that should be send along.
265+
#[serde(skip_serializing_if = "HashMap::is_empty")]
266+
pub data: HashMap<String, Value>,
245267
}
246268

247269
impl Default for Breadcrumb {
@@ -261,26 +283,44 @@ impl Default for Breadcrumb {
261283
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
262284
#[serde(default)]
263285
pub struct User {
286+
/// The ID of the user.
264287
pub id: Option<String>,
288+
/// The email address of the user.
265289
pub email: Option<String>,
290+
/// The remote ip address of the user.
266291
pub ip_address: Option<IpAddr>,
292+
/// A human readable username of the user.
267293
pub username: Option<String>,
268-
#[serde(flatten)] pub data: HashMap<String, Value>,
294+
/// Additional data that should be send along.
295+
#[serde(flatten)]
296+
pub data: HashMap<String, Value>,
269297
}
270298

271299
/// Represents http request data.
272300
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
273301
#[serde(default)]
274302
pub struct Request {
275-
#[serde(with = "url_serde")] pub url: Option<Url>,
303+
/// The current URL of the request.
304+
#[serde(with = "url_serde")]
305+
pub url: Option<Url>,
306+
/// The HTTP request method.
276307
pub method: Option<String>,
308+
/// Optionally some associated request data (human readable)
277309
// XXX: this makes absolutely no sense because of unicode
278310
pub data: Option<String>,
311+
/// Optionally the encoded query string.
279312
pub query_string: Option<String>,
313+
/// An encoded cookie string if available.
280314
pub cookies: Option<String>,
281-
#[serde(skip_serializing_if = "HashMap::is_empty")] pub headers: HashMap<String, String>,
282-
#[serde(skip_serializing_if = "HashMap::is_empty")] pub env: HashMap<String, String>,
283-
#[serde(flatten)] pub other: HashMap<String, Value>,
315+
/// HTTP request headers.
316+
#[serde(skip_serializing_if = "HashMap::is_empty")]
317+
pub headers: HashMap<String, String>,
318+
/// Optionally a CGI/WSGI etc. environment dictionary.
319+
#[serde(skip_serializing_if = "HashMap::is_empty")]
320+
pub env: HashMap<String, String>,
321+
/// Additional unhandled keys.
322+
#[serde(flatten)]
323+
pub other: HashMap<String, Value>,
284324
}
285325

286326
/// Holds information about the system SDK.
@@ -302,8 +342,12 @@ pub struct SystemSdkInfo {
302342
/// Represents a debug image.
303343
#[derive(Debug, Clone, PartialEq)]
304344
pub enum DebugImage {
345+
/// Apple debug images (machos). This is currently also used for
346+
/// non apple platforms with similar debug setups.
305347
Apple(AppleDebugImage),
348+
/// A reference to a proguard debug file.
306349
Proguard(ProguardDebugImage),
350+
/// A debug image that is unknown to this protocol specification.
307351
Unknown(HashMap<String, Value>),
308352
}
309353

@@ -323,19 +367,28 @@ impl DebugImage {
323367
/// Represents an apple debug image in the debug meta.
324368
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
325369
pub struct AppleDebugImage {
370+
/// The name of the debug image (usually filename)
326371
pub name: String,
372+
/// The optional CPU architecture of the debug image.
327373
pub arch: Option<String>,
328-
pub cpu_type: u32,
329-
pub cpu_subtype: u32,
374+
/// Alternatively a macho cpu type.
375+
pub cpu_type: Option<u32>,
376+
/// Alternatively a macho cpu subtype.
377+
pub cpu_subtype: Option<u32>,
378+
/// The starting address of the image.
330379
pub image_addr: u64,
380+
/// The size of the image in bytes.
331381
pub image_size: u64,
382+
/// The address where the image is loaded at runtime.
332383
pub image_vmaddr: u64,
384+
/// The unique UUID of the image.
333385
pub uuid: Uuid,
334386
}
335387

336388
/// Represents a proguard mapping file reference.
337389
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
338390
pub struct ProguardDebugImage {
391+
/// The UUID of the associated proguard file.
339392
pub uuid: Uuid,
340393
}
341394

@@ -372,7 +425,7 @@ pub struct ClientSdkInfo {
372425
pub version: String,
373426
/// An optional list of integrations that are enabled in this SDK.
374427
#[serde(skip_serializing_if = "Vec::is_empty")]
375-
pub integrations: Vec<String>
428+
pub integrations: Vec<String>,
376429
}
377430

378431
/// Represents a full event for Sentry.
@@ -434,9 +487,10 @@ pub struct Event {
434487
#[serde(skip_serializing_if = "HashMap::is_empty", serialize_with = "serialize_context",
435488
deserialize_with = "deserialize_context")]
436489
pub contexts: HashMap<String, Context>,
437-
/// Exceptions to be attached (one or multiple if chained).
490+
/// List of breadcrumbs to send along.
438491
#[serde(skip_serializing_if = "Vec::is_empty")]
439492
pub breadcrumbs: Vec<Breadcrumb>,
493+
/// Exceptions to be attached (one or multiple if chained).
440494
#[serde(skip_serializing_if = "Vec::is_empty", serialize_with = "serialize_exceptions",
441495
deserialize_with = "deserialize_exceptions", rename = "exception")]
442496
pub exceptions: Vec<Exception>,
@@ -559,30 +613,58 @@ pub enum ContextType {
559613
/// Holds device information.
560614
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
561615
pub struct DeviceContext {
562-
#[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>,
563-
#[serde(skip_serializing_if = "Option::is_none")] pub family: Option<String>,
564-
#[serde(skip_serializing_if = "Option::is_none")] pub model: Option<String>,
565-
#[serde(skip_serializing_if = "Option::is_none")] pub model_id: Option<String>,
566-
#[serde(skip_serializing_if = "Option::is_none")] pub arch: Option<String>,
567-
#[serde(skip_serializing_if = "Option::is_none")] pub battery_level: Option<f32>,
568-
#[serde(skip_serializing_if = "Option::is_none")] pub orientation: Option<Orientation>,
616+
/// The name of the device.
617+
#[serde(skip_serializing_if = "Option::is_none")]
618+
pub name: Option<String>,
619+
/// The family of the device model.
620+
#[serde(skip_serializing_if = "Option::is_none")]
621+
pub family: Option<String>,
622+
/// The device model (human readable)
623+
#[serde(skip_serializing_if = "Option::is_none")]
624+
pub model: Option<String>,
625+
/// The device model (internal identifier)
626+
#[serde(skip_serializing_if = "Option::is_none")]
627+
pub model_id: Option<String>,
628+
/// The native cpu architecture of the device.
629+
#[serde(skip_serializing_if = "Option::is_none")]
630+
pub arch: Option<String>,
631+
/// The current battery level (0-100)
632+
#[serde(skip_serializing_if = "Option::is_none")]
633+
pub battery_level: Option<f32>,
634+
/// The current screen orientation.
635+
#[serde(skip_serializing_if = "Option::is_none")]
636+
pub orientation: Option<Orientation>,
569637
}
570638

571639
/// Holds operating system information.
572640
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
573641
pub struct OsContext {
574-
#[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>,
575-
#[serde(skip_serializing_if = "Option::is_none")] pub version: Option<String>,
576-
#[serde(skip_serializing_if = "Option::is_none")] pub build: Option<String>,
577-
#[serde(skip_serializing_if = "Option::is_none")] pub kernel_version: Option<String>,
578-
#[serde(skip_serializing_if = "Option::is_none")] pub rooted: Option<bool>,
642+
/// The name of the operating system.
643+
#[serde(skip_serializing_if = "Option::is_none")]
644+
pub name: Option<String>,
645+
/// The version of the operating system.
646+
#[serde(skip_serializing_if = "Option::is_none")]
647+
pub version: Option<String>,
648+
/// The internal build number of the operating system.
649+
#[serde(skip_serializing_if = "Option::is_none")]
650+
pub build: Option<String>,
651+
/// The current kernel version
652+
#[serde(skip_serializing_if = "Option::is_none")]
653+
pub kernel_version: Option<String>,
654+
/// An indicator if the os is rooted (mobile mostly)
655+
#[serde(skip_serializing_if = "Option::is_none")]
656+
pub rooted: Option<bool>,
579657
}
580658

581659
/// Holds information about the runtime.
582660
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
583661
pub struct RuntimeContext {
584-
#[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>,
585-
#[serde(skip_serializing_if = "Option::is_none")] pub version: Option<String>,
662+
/// The name of the runtime (for instance JVM)
663+
#[serde(skip_serializing_if = "Option::is_none")]
664+
pub name: Option<String>,
665+
/// The version of the runtime
666+
#[serde(skip_serializing_if = "Option::is_none")]
667+
pub version: Option<String>,
586668
}
587669

588670
impl From<ContextType> for Context {

0 commit comments

Comments
 (0)