aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-test-support/src/lib.rs
blob: cc2e9e89f3dfba0fab12867579664887bf819ba2 (plain) (blame)
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
#![forbid(unsafe_code)]
#![cfg_attr(
    test,
    allow(
        clippy::cast_possible_truncation,
        clippy::cast_possible_wrap,
        clippy::cast_precision_loss,
        clippy::expect_used,
        clippy::float_cmp,
        clippy::identity_op,
        clippy::too_many_lines,
        clippy::uninlined_format_args,
        clippy::map_unwrap_or,
        clippy::needless_raw_string_hashes,
        clippy::semicolon_if_nothing_returned,
        clippy::type_complexity,
        clippy::panic,
        clippy::unwrap_used
    )
)]
//! Dev-only synthetic builders and fake ports.

use fparkan_render::{FrameOutput, RenderBackend, RenderCommandList, RenderError};

/// Fake clock.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct FakeClock {
    /// Current tick.
    pub tick: u64,
}

/// Recording backend.
#[derive(Clone, Debug, Default)]
pub struct RecordingRenderBackend {
    /// Recorded command lists.
    pub captures: Vec<RenderCommandList>,
}

impl RenderBackend for RecordingRenderBackend {
    fn execute(&mut self, commands: &RenderCommandList) -> Result<FrameOutput, RenderError> {
        self.captures.push(commands.clone());
        Ok(FrameOutput)
    }
}