Skip to main content

socorro_cli/models/
common.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5use serde::{Deserialize, Deserializer, Serialize};
6
7pub fn deserialize_string_or_number<'de, D>(
8    deserializer: D,
9) -> std::result::Result<Option<String>, D::Error>
10where
11    D: Deserializer<'de>,
12{
13    let value: Option<serde_json::Value> = Option::deserialize(deserializer)?;
14    Ok(value.map(|v| match v {
15        serde_json::Value::String(s) => s,
16        serde_json::Value::Number(n) => n.to_string(),
17        other => other.to_string(),
18    }))
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct StackFrame {
23    #[serde(default)]
24    pub frame: u32,
25    pub function: Option<String>,
26    pub file: Option<String>,
27    pub line: Option<u32>,
28    pub module: Option<String>,
29    pub offset: Option<String>,
30}