1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use Infallible;
use ;
// Record-only host: a long-lived global sink isn't available in `no_std` (the thread-
// local slot is std-only), so `magic!` runs in its pure `EMT_MAGIC` configuration:
// only the MGIC record is emitted, with no `emt_default_*` host functions at all.
// Because no global pointer serializer exists, `.ptr_width`/`.alignment_power` could
// independently set the record's advertised pointer dimensions; the defaults
// (`size_of::<usize>()`, this crate's `ALIGNMENT_POWER`) match the
// `ShiftPtrSerializer::new()` used below, so they are left out here.
//
// With no global sink, every `trace!` must supply its own `.sink`/`.sink_guard` - a
// default-sink trace would fail to link (`emt_default_begin` & co. undefined), exactly
// like a C `EMT_MAGIC`-only binary whose records are driven through user-provided
// output code.
magic!;
const CAPACITY: usize = 1024;
/// This demo tests that the crate works in a [no_std] environment
/// The default sink used by the `trace!` macro requires std, to print to stdout.
/// We instead provide as an output sink a static vector with limited capacity, and
/// the local-shift pointer serializer, since - with `.no_global_ptr_serializer` -
/// no host-defined `emt_default_serialize_pointer` exists to delegate to.
///
/// Both option values are *borrowed* per call, so a single `StaticVec`/serializer can
/// serve every `trace!` statement; no per-call construction is needed.