Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:38:39.198Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

lib.rs

101 lines · 1.9 KB · rust
1//! Minimal stand-in for the real `gpui` crate. The lints key off the crate
2//! name and the type names, so we only need to reproduce the relevant API
3//! surface.
4
5use std::marker::PhantomData;
6
7// --- AppContext ---
8
9pub trait AppContext {
10    fn as_app_mut(&mut self) -> &mut App;
11}
12
13// --- App ---
14
15pub struct App;
16
17impl AppContext for App {
18    fn as_app_mut(&mut self) -> &mut App {
19        self
20    }
21}
22
23// --- Context ---
24
25pub struct Context<'a, T> {
26    _marker: PhantomData<&'a mut T>,
27}
28
29impl<T> AppContext for Context<'_, T> {
30    fn as_app_mut(&mut self) -> &mut App {
31        unimplemented!()
32    }
33}
34
35impl<T> Context<'_, T> {
36    pub fn notify(&mut self) {}
37}
38
39// --- Window ---
40
41pub struct Window;
42
43// --- Entity ---
44
45pub struct Entity<T> {
46    _marker: PhantomData<T>,
47}
48
49impl<T> Entity<T> {
50    pub fn update<R, C: AppContext>(
51        &self,
52        _cx: &mut C,
53        _f: impl FnOnce(&mut T, &mut Context<T>) -> R,
54    ) -> R {
55        unimplemented!()
56    }
57
58    pub fn read<'a>(&self, _cx: &'a App) -> &'a T {
59        unimplemented!()
60    }
61
62    pub fn read_with<R>(&self, _cx: &App, _f: impl FnOnce(&T, &App) -> R) -> R {
63        unimplemented!()
64    }
65
66    pub fn downgrade(&self) -> WeakEntity<T> {
67        unimplemented!()
68    }
69}
70
71// --- WeakEntity ---
72
73pub struct WeakEntity<T> {
74    _marker: PhantomData<T>,
75}
76
77impl<T> WeakEntity<T> {
78    pub fn update<R, C: AppContext>(
79        &self,
80        _cx: &mut C,
81        _f: impl FnOnce(&mut T, &mut Context<T>) -> R,
82    ) -> Result<R, ()> {
83        unimplemented!()
84    }
85}
86
87// --- Render traits ---
88
89pub trait IntoElement {}
90
91pub trait Render: 'static + Sized {
92    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement;
93}
94
95pub trait RenderOnce: 'static {
96    fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement;
97}
98
99impl IntoElement for () {}
100impl IntoElement for &str {}
101
Served at tenant.openagents/omega Member data and write actions are omitted.