1use std::default::Default;
5use std::fmt::{Display, Formatter, Result};
6
7#[derive(Default)]
9pub enum CodeFormat {
10 #[default]
11 None,
12 Hex,
13 Disassembly,
14}
15
16#[derive(Default)]
18pub struct Options {
19 pub code_format: CodeFormat,
21
22 pub recursive: bool,
24}
25
26pub trait DisplayWithOptions: Display {
28 fn fmt_with_options(&self, f: &mut Formatter<'_>, _options: &Options) -> Result {
29 self.fmt(f)
30 }
31}
32
33pub struct PsyXDisplayable<'a, P: DisplayWithOptions> {
34 p: &'a P,
35 options: Options,
36}
37
38impl<'a, P> PsyXDisplayable<'a, P>
39where
40 P: DisplayWithOptions,
41{
42 pub fn wrap(p: &'a P, options: Options) -> PsyXDisplayable<'a, P> {
43 Self { p, options }
44 }
45}
46
47impl<P> Display for PsyXDisplayable<'_, P>
48where
49 P: DisplayWithOptions,
50{
51 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
52 self.p.fmt_with_options(f, &self.options)
53 }
54}