| // Copyright 2020 The Pigweed Authors |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| // use this file except in compliance with the License. You may obtain a copy of |
| // the License at |
| // |
| // https://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| // License for the specific language governing permissions and limitations under |
| // the License. |
| #pragma once |
| |
| #include <cstddef> |
| #include <cstdint> |
| |
| #include "pw_rpc/internal/call_context.h" |
| |
| namespace pw::rpc { |
| |
| // The ServerContext class is DEPRECATED and will be removed from pw_rpc. All |
| // information in the ServerContext is accessible through the |
| // ServerReader/Writer object. |
| // |
| // The only case where the information in a ServerContext is not available is |
| // synchronous unary RPCs. If information like channel_id() is needed in a unary |
| // RPC, just use an asynchronous unary RPC. |
| class ServerContext : private internal::CallContext { |
| public: |
| constexpr ServerContext() = delete; |
| |
| constexpr ServerContext(const ServerContext&) = delete; |
| constexpr ServerContext& operator=(const ServerContext&) = delete; |
| |
| constexpr ServerContext(ServerContext&&) = delete; |
| constexpr ServerContext& operator=(ServerContext&&) = delete; |
| |
| friend class internal::CallContext; // Allow down-casting from CallContext. |
| }; |
| |
| namespace internal { |
| |
| inline ServerContext& CallContext::context() { |
| return static_cast<ServerContext&>(*this); |
| } |
| |
| } // namespace internal |
| } // namespace pw::rpc |