pub struct ThemeRegistry { /* private fields */ }Expand description
A registry of discovered custom theme files: display name → path.
Built once per TUI session by scanning the resource theme dirs; names are
file stems, first-wins on conflict (project .rpi/themes overrides the
global ~/.rpi/agent/themes). Parsing is lazy: the registry only lists
files, and a theme is parsed when selected or applied, so a broken JSON
file cannot break the other themes.
Implementations§
Source§impl ThemeRegistry
impl ThemeRegistry
Sourcepub fn merge_discovered(&mut self, paths: &[String])
pub fn merge_discovered(&mut self, paths: &[String])
Merge bare extension-contributed theme file paths (resources_discover
themePaths) into this registry.
Priority sits after the static dirs: a static dir theme of the same
stem wins, extension themes fill the remaining names. This matches the
skill/prompt precedence (static first-wins, discovered lower). Paths are
concrete .json files (the pi contract, unlike skills’ dir-or-file);
names are file stems. v1 divergence (documented upstream parity gap):
paths are unattributed, so diagnostics can only name the path.
Sourcepub fn discover(cwd: &Path, project_trusted: bool) -> (Self, Vec<String>)
pub fn discover(cwd: &Path, project_trusted: bool) -> (Self, Vec<String>)
Scan the global + project theme dirs. Project themes win on name
conflicts. project_trusted == false skips the project dir entirely
(the same trust boundary as skills: an untrusted repo must not shape
the UI on first open).
Returns the registry plus soft diagnostics for unreadable dirs.
Sourcepub fn discover_from(
global: Option<&Path>,
project: Option<&Path>,
) -> (Self, Vec<String>)
pub fn discover_from( global: Option<&Path>, project: Option<&Path>, ) -> (Self, Vec<String>)
Scan explicit dirs (test seam; discover resolves the standard dirs).
Sourcepub fn get(&self, name: &str) -> Option<&PathBuf>
pub fn get(&self, name: &str) -> Option<&PathBuf>
Look up a discovered theme by name (file stem, case-sensitive).
Sourcepub fn names(&self) -> impl Iterator<Item = &String>
pub fn names(&self) -> impl Iterator<Item = &String>
Discovered names in display order (alphabetical).
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Trait Implementations§
Source§impl Clone for ThemeRegistry
impl Clone for ThemeRegistry
Source§impl Debug for ThemeRegistry
impl Debug for ThemeRegistry
Auto Trait Implementations§
impl Freeze for ThemeRegistry
impl RefUnwindSafe for ThemeRegistry
impl Send for ThemeRegistry
impl Sync for ThemeRegistry
impl Unpin for ThemeRegistry
impl UnsafeUnpin for ThemeRegistry
impl UnwindSafe for ThemeRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> MaybeSendSync for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().