@@ -81,33 +81,50 @@ impl<D: crate::store::Store> Blobs<D> {
81
81
where
82
82
C : ChannelTypes < RpcService > ,
83
83
{
84
- use Request :: * ;
85
- let handler = Handler ( self ) ;
86
- match msg {
87
- Blobs ( msg) => handler. handle_blobs_request ( msg, chan) . await ,
88
- Tags ( msg) => handler. handle_tags_request ( msg, chan) . await ,
89
- }
84
+ Handler {
85
+ blobs : self . clone ( ) ,
86
+ store : self . store . clone ( ) ,
87
+ } . handle_rpc_request ( msg, chan) . await
90
88
}
91
89
}
92
90
93
91
#[ derive( Clone ) ]
94
- struct Handler < S > ( Arc < Blobs < S > > ) ;
92
+ struct Handler < S > {
93
+ blobs : Arc < Blobs < S > > ,
94
+ store : S ,
95
+ }
95
96
96
97
impl < S > Deref for Handler < S > {
97
98
type Target = Blobs < S > ;
98
99
99
100
fn deref ( & self ) -> & Self :: Target {
100
- & self . 0
101
+ & self . blobs
101
102
}
102
103
}
103
104
104
105
impl < D : crate :: store:: Store > Handler < D > {
105
106
fn store ( & self ) -> & D {
106
- & self . 0 . store
107
+ & self . store
108
+ }
109
+
110
+ /// Handle an RPC request
111
+ pub async fn handle_rpc_request < C > (
112
+ self ,
113
+ msg : Request ,
114
+ chan : RpcChannel < RpcService , C > ,
115
+ ) -> std:: result:: Result < ( ) , RpcServerError < C > >
116
+ where
117
+ C : ChannelTypes < RpcService > ,
118
+ {
119
+ use Request :: * ;
120
+ match msg {
121
+ Blobs ( msg) => self . handle_blobs_request ( msg, chan) . await ,
122
+ Tags ( msg) => self . handle_tags_request ( msg, chan) . await ,
123
+ }
107
124
}
108
125
109
126
/// Handle a tags request
110
- pub async fn handle_tags_request < C > (
127
+ async fn handle_tags_request < C > (
111
128
self ,
112
129
msg : proto:: tags:: Request ,
113
130
chan : RpcChannel < proto:: RpcService , C > ,
@@ -125,7 +142,7 @@ impl<D: crate::store::Store> Handler<D> {
125
142
}
126
143
127
144
/// Handle a blobs request
128
- pub async fn handle_blobs_request < C > (
145
+ async fn handle_blobs_request < C > (
129
146
self ,
130
147
msg : proto:: blobs:: Request ,
131
148
chan : RpcChannel < proto:: RpcService , C > ,
0 commit comments