Skip to content

Commit a97f5f3

Browse files
authored
Merge pull request #3064 from spinframework/app-id-shared
app: Use an Arc<str> for App::id
2 parents 63364f5 + 9f0782b commit a97f5f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/app/src/lib.rs

Lines changed: 7 additions & 2 deletions
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)