polyhorn_core/
platform.rs

1use std::hash::Hash;
2
3use super::{CommandBuffer, Component, Compositor, Container, Disposable, EventLoop};
4
5/// This is a platform that needs to be implemented by every render host.
6pub trait Platform: 'static {
7    /// This is a virtual container that renders a built-in. These containers
8    /// should be thread-safe (e.g. `Send + Sync`).
9    type ContainerID: Copy + Eq + Hash + Send;
10
11    /// This is a native container that renders a built-in. For example, this can
12    /// be an UIView or a div. Native containers are usually not thread-safe and
13    /// reside only on the main thread.
14    type Container: Container<Self>;
15
16    type Component: Component<Self>;
17
18    type Compositor: Compositor<Self>;
19
20    type CommandBuffer: CommandBuffer<Self>;
21
22    type Environment;
23
24    fn with_compositor<F>(container: Self::Container, task: F) -> Disposable
25    where
26        F: FnOnce(Self::ContainerID, Self::Compositor, EventLoop) -> Disposable + Send + 'static;
27}