Skip to content

Commit 9f0782b

Browse files
committed
app: Use an Arc<str> for App::id
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
1 parent 63364f5 commit 9f0782b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: crates/app/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ pub type ValidatorFn = dyn Fn(&App, &[&str]) -> anyhow::Result<()>;
3737
/// An `App` holds loaded configuration for a Spin application.
3838
#[derive(Debug, Clone)]
3939
pub struct App {
40-
id: String,
40+
id: Arc<str>,
4141
locked: Arc<LockedApp>,
4242
}
4343

4444
impl App {
4545
/// Returns a new app for the given runtime-specific identifier and locked
4646
/// app.
47-
pub fn new(id: impl Into<String>, locked: LockedApp) -> Self {
47+
pub fn new(id: impl Into<Arc<str>>, locked: LockedApp) -> Self {
4848
Self {
4949
id: id.into(),
5050
locked: Arc::new(locked),
@@ -56,6 +56,11 @@ impl App {
5656
&self.id
5757
}
5858

59+
/// Returns a runtime-specific identifier for this app.
60+
pub fn id_shared(&self) -> Arc<str> {
61+
self.id.clone()
62+
}
63+
5964
/// Deserializes typed metadata for this app.
6065
///
6166
/// Returns `Ok(None)` if there is no metadata for the given `key` and an

0 commit comments

Comments
 (0)