@@ -82,6 +82,10 @@ pub trait Context {
8282 hostcalls:: get_map ( MapType :: HttpCallResponseHeaders ) . unwrap ( )
8383 }
8484
85+ fn get_http_call_response_header ( & self , name : & str ) -> Option < String > {
86+ hostcalls:: get_map_value ( MapType :: HttpCallResponseHeaders , & name) . unwrap ( )
87+ }
88+
8589 fn get_http_call_response_body ( & self , start : usize , max_size : usize ) -> Option < Bytes > {
8690 hostcalls:: get_buffer ( BufferType :: HttpCallResponseBody , start, max_size) . unwrap ( )
8791 }
@@ -90,6 +94,10 @@ pub trait Context {
9094 hostcalls:: get_map ( MapType :: HttpCallResponseTrailers ) . unwrap ( )
9195 }
9296
97+ fn get_http_call_response_trailer ( & self , name : & str ) -> Option < String > {
98+ hostcalls:: get_map_value ( MapType :: HttpCallResponseTrailers , & name) . unwrap ( )
99+ }
100+
93101 fn dispatch_grpc_call (
94102 & self ,
95103 upstream_name : & str ,
@@ -115,8 +123,8 @@ pub trait Context {
115123 hostcalls:: get_buffer ( BufferType :: GrpcReceiveBuffer , start, max_size) . unwrap ( )
116124 }
117125
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 ( )
120128 }
121129
122130 fn open_grpc_stream (
@@ -131,17 +139,16 @@ pub trait Context {
131139
132140 fn on_grpc_stream_initial_metadata ( & mut self , _token_id : u32 , _num_elements : u32 ) { }
133141
134- fn get_grpc_stream_initial_metadata ( & self ) -> Vec < ( String , Vec < u8 > ) > {
142+ fn get_grpc_stream_initial_metadata ( & self ) -> Vec < ( String , Bytes ) > {
135143 hostcalls:: get_map_bytes ( MapType :: GrpcReceiveInitialMetadata ) . unwrap ( )
136144 }
137145
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 ( )
145152 }
146153
147154 fn on_grpc_stream_message ( & mut self , _token_id : u32 , _message_size : usize ) { }
@@ -152,16 +159,28 @@ pub trait Context {
152159
153160 fn on_grpc_stream_trailing_metadata ( & mut self , _token_id : u32 , _num_elements : u32 ) { }
154161
155- fn get_grpc_stream_trailing_metadata ( & self ) -> Vec < ( String , Vec < u8 > ) > {
162+ fn get_grpc_stream_trailing_metadata ( & self ) -> Vec < ( String , Bytes ) > {
156163 hostcalls:: get_map_bytes ( MapType :: GrpcReceiveTrailingMetadata ) . unwrap ( )
157164 }
158165
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 ( )
161176 }
162177
163178 fn on_grpc_stream_close ( & mut self , _token_id : u32 , _status_code : u32 ) { }
164179
180+ fn get_grpc_status ( & self ) -> ( u32 , Option < String > ) {
181+ hostcalls:: get_grpc_status ( ) . unwrap ( )
182+ }
183+
165184 fn on_done ( & mut self ) -> bool {
166185 true
167186 }
0 commit comments