@@ -82,6 +82,10 @@ pub trait Context {
82
82
hostcalls:: get_map ( MapType :: HttpCallResponseHeaders ) . unwrap ( )
83
83
}
84
84
85
+ fn get_http_call_response_header ( & self , name : & str ) -> Option < String > {
86
+ hostcalls:: get_map_value ( MapType :: HttpCallResponseHeaders , & name) . unwrap ( )
87
+ }
88
+
85
89
fn get_http_call_response_body ( & self , start : usize , max_size : usize ) -> Option < Bytes > {
86
90
hostcalls:: get_buffer ( BufferType :: HttpCallResponseBody , start, max_size) . unwrap ( )
87
91
}
@@ -90,6 +94,10 @@ pub trait Context {
90
94
hostcalls:: get_map ( MapType :: HttpCallResponseTrailers ) . unwrap ( )
91
95
}
92
96
97
+ fn get_http_call_response_trailer ( & self , name : & str ) -> Option < String > {
98
+ hostcalls:: get_map_value ( MapType :: HttpCallResponseTrailers , & name) . unwrap ( )
99
+ }
100
+
93
101
fn dispatch_grpc_call (
94
102
& self ,
95
103
upstream_name : & str ,
@@ -115,8 +123,8 @@ pub trait Context {
115
123
hostcalls:: get_buffer ( BufferType :: GrpcReceiveBuffer , start, max_size) . unwrap ( )
116
124
}
117
125
118
- fn cancel_grpc_call ( & self , token_id : u32 ) -> Result < ( ) , Status > {
119
- hostcalls:: cancel_grpc_call ( token_id)
126
+ fn cancel_grpc_call ( & self , token_id : u32 ) {
127
+ hostcalls:: cancel_grpc_call ( token_id) . unwrap ( )
120
128
}
121
129
122
130
fn open_grpc_stream (
@@ -131,17 +139,16 @@ pub trait Context {
131
139
132
140
fn on_grpc_stream_initial_metadata ( & mut self , _token_id : u32 , _num_elements : u32 ) { }
133
141
134
- fn get_grpc_stream_initial_metadata ( & self ) -> Vec < ( String , Vec < u8 > ) > {
142
+ fn get_grpc_stream_initial_metadata ( & self ) -> Vec < ( String , Bytes ) > {
135
143
hostcalls:: get_map_bytes ( MapType :: GrpcReceiveInitialMetadata ) . unwrap ( )
136
144
}
137
145
138
- fn send_grpc_stream_message (
139
- & self ,
140
- token_id : u32 ,
141
- message : Option < & [ u8 ] > ,
142
- end_stream : bool ,
143
- ) -> Result < ( ) , Status > {
144
- hostcalls:: send_grpc_stream_message ( token_id, message, end_stream)
146
+ fn get_grpc_stream_initial_metadata_value ( & self , name : & str ) -> Option < Bytes > {
147
+ hostcalls:: get_map_value_bytes ( MapType :: GrpcReceiveInitialMetadata , & name) . unwrap ( )
148
+ }
149
+
150
+ fn send_grpc_stream_message ( & self , token_id : u32 , message : Option < & [ u8 ] > , end_stream : bool ) {
151
+ hostcalls:: send_grpc_stream_message ( token_id, message, end_stream) . unwrap ( )
145
152
}
146
153
147
154
fn on_grpc_stream_message ( & mut self , _token_id : u32 , _message_size : usize ) { }
@@ -152,16 +159,28 @@ pub trait Context {
152
159
153
160
fn on_grpc_stream_trailing_metadata ( & mut self , _token_id : u32 , _num_elements : u32 ) { }
154
161
155
- fn get_grpc_stream_trailing_metadata ( & self ) -> Vec < ( String , Vec < u8 > ) > {
162
+ fn get_grpc_stream_trailing_metadata ( & self ) -> Vec < ( String , Bytes ) > {
156
163
hostcalls:: get_map_bytes ( MapType :: GrpcReceiveTrailingMetadata ) . unwrap ( )
157
164
}
158
165
159
- fn close_grpc_stream ( & self , token_id : u32 ) -> Result < ( ) , Status > {
160
- hostcalls:: close_grpc_stream ( token_id)
166
+ fn get_grpc_stream_trailing_metadata_value ( & self , name : & str ) -> Option < Bytes > {
167
+ hostcalls:: get_map_value_bytes ( MapType :: GrpcReceiveTrailingMetadata , & name) . unwrap ( )
168
+ }
169
+
170
+ fn cancel_grpc_stream ( & self , token_id : u32 ) {
171
+ hostcalls:: cancel_grpc_stream ( token_id) . unwrap ( )
172
+ }
173
+
174
+ fn close_grpc_stream ( & self , token_id : u32 ) {
175
+ hostcalls:: close_grpc_stream ( token_id) . unwrap ( )
161
176
}
162
177
163
178
fn on_grpc_stream_close ( & mut self , _token_id : u32 , _status_code : u32 ) { }
164
179
180
+ fn get_grpc_status ( & self ) -> ( u32 , Option < String > ) {
181
+ hostcalls:: get_grpc_status ( ) . unwrap ( )
182
+ }
183
+
165
184
fn on_done ( & mut self ) -> bool {
166
185
true
167
186
}
0 commit comments