LCOV - code coverage report
Current view: top level - wirestead/interface - result_channel.hpp (source / functions) Coverage Total Hit
Test: Wirestead Coverage Report Lines: 100.0 % 10 10
Test Date: 2026-10-29 11:36:05 Functions: 100.0 % 6 6
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright 2025 Jinwoo Sung
       3                 :             :  *
       4                 :             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :             :  * you may not use this file except in compliance with the License.
       6                 :             :  * You may obtain a copy of the License at
       7                 :             :  *
       8                 :             :  *     http://www.apache.org/licenses/LICENSE-2.0
       9                 :             :  *
      10                 :             :  * Unless required by applicable law or agreed to in writing, software
      11                 :             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :             :  * See the License for the specific language governing permissions and
      14                 :             :  * limitations under the License.
      15                 :             :  */
      16                 :             : 
      17                 :             : #pragma once
      18                 :             : 
      19                 :             : #include "wirestead/interface/channel.hpp"
      20                 :             : #include "wirestead/wrapper/send_result.hpp"
      21                 :             : 
      22                 :             : namespace wirestead::interface {
      23                 :             : 
      24                 :             : /**
      25                 :             :  * Single-target write admission capability for built-in and custom channels.
      26                 :             :  *
      27                 :             :  * Results describe local queue acceptance only. Implementations choose rejection
      28                 :             :  * reasons at admission; they must not infer them after a bool-only write.
      29                 :             :  * These calls do not wait for capacity. A refused move retains its input.
      30                 :             :  * Shared ownership may be retained only for accepted work.
      31                 :             :  *
      32                 :             :  * Channel remains the legacy bool interface, including transports whose writes
      33                 :             :  * fan out. A fanout implementation must not collapse partial results into this
      34                 :             :  * capability. The bool adapters below intentionally expose acceptance only.
      35                 :             :  */
      36                 :             : class WIRESTEAD_API ResultChannel : public Channel {
      37                 :             :  public:
      38                 :             :   using SendResult = wrapper::SendResult;
      39                 :             : 
      40                 :             :   [[nodiscard]] virtual SendResult async_write_copy_result(memory::ConstByteSpan data) = 0;
      41                 :             :   [[nodiscard]] virtual SendResult async_write_move_result(std::vector<uint8_t>&& data) = 0;
      42                 :             :   [[nodiscard]] virtual SendResult async_write_shared_result(std::shared_ptr<const std::vector<uint8_t>> data) = 0;
      43                 :             :   [[nodiscard]] virtual SendResult async_try_write_copy_result(memory::ConstByteSpan data) = 0;
      44                 :             :   [[nodiscard]] virtual SendResult async_try_write_move_result(std::vector<uint8_t>&& data) = 0;
      45                 :             :   [[nodiscard]] virtual SendResult async_try_write_shared_result(std::shared_ptr<const std::vector<uint8_t>> data) = 0;
      46                 :             : 
      47                 :         499 :   bool async_write_copy(memory::ConstByteSpan data) final { return async_write_copy_result(data).accepted(); }
      48                 :         602 :   bool async_write_move(std::vector<uint8_t>&& data) final {
      49                 :         602 :     return async_write_move_result(std::move(data)).accepted();
      50                 :             :   }
      51                 :         299 :   bool async_write_shared(std::shared_ptr<const std::vector<uint8_t>> data) final {
      52                 :         299 :     return async_write_shared_result(std::move(data)).accepted();
      53                 :             :   }
      54                 :      266218 :   bool async_try_write_copy(memory::ConstByteSpan data) final { return async_try_write_copy_result(data).accepted(); }
      55                 :         348 :   bool async_try_write_move(std::vector<uint8_t>&& data) final {
      56                 :         348 :     return async_try_write_move_result(std::move(data)).accepted();
      57                 :             :   }
      58                 :         287 :   bool async_try_write_shared(std::shared_ptr<const std::vector<uint8_t>> data) final {
      59                 :         287 :     return async_try_write_shared_result(std::move(data)).accepted();
      60                 :             :   }
      61                 :             : };
      62                 :             : 
      63                 :             : }  // namespace wirestead::interface
        

Generated by: LCOV version 2.0-1