1 // Copyright 2022 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 #include <string> 17 18 #include "grpcpp/support/sync_stream.h" 19 #include "netsim/frontend.pb.h" 20 #include "rust/cxx.h" 21 22 namespace netsim { 23 namespace frontend { 24 25 /// The C++ definition of the CxxServerResponseWriter interface for CXX. 26 class CxxServerResponseWriter { 27 public: CxxServerResponseWriter()28 CxxServerResponseWriter() {}; CxxServerResponseWriter(grpc::ServerWriter<netsim::frontend::GetCaptureResponse> * grpc_writer_)29 CxxServerResponseWriter( 30 grpc::ServerWriter<netsim::frontend::GetCaptureResponse> *grpc_writer_) { 31 }; 32 virtual ~CxxServerResponseWriter() = default; 33 virtual void put_error(unsigned int error_code, 34 const std::string &response) const = 0; 35 virtual void put_ok_with_length(const std::string &mime_type, 36 std::size_t length) const = 0; 37 virtual void put_chunk(rust::Slice<const uint8_t> chunk) const = 0; 38 virtual void put_ok(const std::string &mime_type, 39 const std::string &body) const = 0; 40 }; 41 42 } // namespace frontend 43 } // namespace netsim 44