File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 6565#[ derive( Debug , Clone ) ]
6666pub struct StacStore {
6767 store : Arc < dyn ObjectStore > ,
68- root : Url ,
68+ root : Option < Url > ,
6969}
7070
7171impl 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) ]
158172mod tests {
159173 use stac:: { Item , SelfHref } ;
You can’t perform that action at this time.
0 commit comments