probe-rs-target 0.32.0

Target description schema for probe-rs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::serialize_u_int::SerializeUnsignedInt;
use serde::Serializer;

pub(crate) fn serialize<T, S>(memory_address: &T, serializer: S) -> Result<S::Ok, S::Error>
where
    S: Serializer,
    T: std::fmt::LowerHex + SerializeUnsignedInt,
{
    // We serialize the range as hex strings when generating human-readable formats such as YAML
    let check_for_human_readable = serializer.is_human_readable();
    if check_for_human_readable {
        serializer.serialize_str(format!("{memory_address:#x}").as_str())
    } else {
        memory_address.serialize_int(serializer)
    }
}