File tree 2 files changed +44
-1
lines changed
2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change
1
+ use std:: {
2
+ any:: { Any , TypeId } ,
3
+ collections:: HashMap ,
4
+ sync:: Arc ,
5
+ } ;
6
+
7
+ type ExtensionMap = HashMap < TypeId , Ext > ;
8
+ type Ext = Arc < dyn Any + Send + Sync + ' static > ;
9
+
10
+ #[ derive( Debug , Default , Clone ) ]
11
+ pub struct Extensions {
12
+ inner : ExtensionMap ,
13
+ }
14
+
15
+ impl Extensions {
16
+ fn set_ext < T : Send + Sync + ' static > ( & mut self , t : T ) {
17
+ let id = t. type_id ( ) ;
18
+ let a = Arc :: new ( t) ;
19
+ self . inner . insert ( id, a) ;
20
+ }
21
+
22
+ fn get_ext < T : Send + Sync + ' static > ( & self ) -> Option < Arc < T > > {
23
+ let id = TypeId :: of :: < T > ( ) ;
24
+ self . inner
25
+ . get ( & id)
26
+ . cloned ( )
27
+ . map ( |e| Arc :: downcast ( e) . expect ( "TypeId is always unique" ) )
28
+ }
29
+ }
30
+
31
+ impl From < HashMap < TypeId , Ext > > for Extensions {
32
+ fn from ( inner : HashMap < TypeId , Ext > ) -> Self {
33
+ Self { inner }
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -536,6 +536,7 @@ mod config;
536
536
537
537
mod tags;
538
538
539
+ pub use extensions:: Extensions ;
539
540
pub use tags:: TagSet ;
540
541
541
542
pub mod multipart;
@@ -545,6 +546,7 @@ mod upload;
545
546
mod util;
546
547
547
548
mod attributes;
549
+ mod extensions;
548
550
549
551
#[ cfg( any( feature = "integration" , test) ) ]
550
552
pub mod integration;
@@ -910,7 +912,6 @@ pub struct ObjectMeta {
910
912
/// A version indicator for this object
911
913
pub version : Option < String > ,
912
914
}
913
-
914
915
/// Options for a get request, such as range
915
916
#[ derive( Debug , Default , Clone ) ]
916
917
pub struct GetOptions {
@@ -963,6 +964,13 @@ pub struct GetOptions {
963
964
///
964
965
/// <https://datatracker.ietf.org/doc/html/rfc9110#name-head>
965
966
pub head : bool ,
967
+
968
+ /// Implementation-specific extensions. but
969
+ /// intended for use by [`ObjectStore`] implementations that need to pass context-specific
970
+ /// information (like tracing spans) via trait methods.
971
+ ///
972
+ /// These extensions are ignored entirely by backends offered through this crate.
973
+ pub extensions : Extensions ,
966
974
}
967
975
968
976
impl GetOptions {
You can’t perform that action at this time.
0 commit comments