Skip to content

Commit a60860e

Browse files
authored
fix: make root optional for stac store (#763)
1 parent 589b18a commit a60860e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

crates/io/src/store.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ where
6565
#[derive(Debug, Clone)]
6666
pub struct StacStore {
6767
store: Arc<dyn ObjectStore>,
68-
root: Url,
68+
root: Option<Url>,
6969
}
7070

7171
impl StacStore {
@@ -86,7 +86,7 @@ impl StacStore {
8686
pub fn new(store: Arc<dyn ObjectStore>, root: Url) -> StacStore {
8787
StacStore {
8888
store: Arc::new(store),
89-
root,
89+
root: Some(root),
9090
}
9191
}
9292

@@ -112,7 +112,9 @@ impl StacStore {
112112
let get_result = self.store.get(&path).await?;
113113
let bytes = get_result.bytes().await?;
114114
let mut value: T = format.from_bytes(bytes)?;
115-
value.set_self_href(self.root.join(path.as_ref())?);
115+
if let Some(root) = self.root.as_ref() {
116+
value.set_self_href(root.join(path.as_ref())?);
117+
}
116118
Ok(value)
117119
}
118120

@@ -154,6 +156,18 @@ impl StacStore {
154156
}
155157
}
156158

159+
impl<T> From<T> for StacStore
160+
where
161+
T: ObjectStore,
162+
{
163+
fn from(store: T) -> Self {
164+
StacStore {
165+
store: Arc::new(store),
166+
root: None,
167+
}
168+
}
169+
}
170+
157171
#[cfg(test)]
158172
mod tests {
159173
use stac::{Item, SelfHref};

0 commit comments

Comments
 (0)