/* * Copyright (C) 2024-present ScyllaDB */ /* * SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0 */ #pragma once #include #include // A contiguous buffer of char objects which can be trimmed and // supports zero-copy sharing of its underlying memory. template concept ContiguousSharedBuffer = std::movable && std::default_initializable && requires(T& obj, size_t pos, size_t len) { // Creates a new buffer that shares the memory of the original buffer. // The lifetime of the new buffer is independent of the original buffer. { obj.share() } -> std::same_as; // Like share() but the new buffer represents a sub-range of the original buffer. { obj.share(pos, len) } -> std::same_as; // Trims the suffix of a buffer so that 'len' is the index of the first removed byte. { obj.trim(len) } -> std::same_as; // Trims the prefix of the buffer so that `pos` is the index of the first byte after the trim. { obj.trim_front(pos) } -> std::same_as; { obj.begin() } -> std::same_as; { obj.get() } -> std::same_as; { obj.get_write() } -> std::same_as; { obj.end() } -> std::same_as; { obj.size() } -> std::same_as; { obj.empty() } -> std::same_as; };