Files
TrustTunnelClient/core/include/vpn/internal/data_buffer.h
T
Nikita Gorskikh 72461d0994 Pull request #2: Put the open-source part of the VPN client library here
Merge in ADGUARD-CORE-LIBS/vpn-libs from feature/add_opensource_vpn_client to master

Squashed commit of the following:

commit 0b68e8bebcb5ab4ab76aa5d63267f224c5bd56f2
Author: Sergei Gunchenko <s.gunchenko@adguard.com>
Date:   Mon Aug 1 19:28:49 2022 +0300

    common/src/utils.cpp edited online with Bitbucket

commit 237afe76b1e03c8e95fd7564b100d72956598550
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 16:58:00 2022 +0300

    Maybe fix conan-upload-recipes

commit 940c4abfc8808b7e464a37302d7eca5215eda14e
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 16:57:52 2022 +0300

    Un-simplify conan export script

commit c6ee05e3642d27daadf6b1d49374b187bdeec818
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 16:51:12 2022 +0300

    Debug

commit b3956633a8ad4d6ada4559b2fc4fb0d4d09e97ea
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 16:49:27 2022 +0300

    Maybe fix upload-conan-recipes 2

commit 447f05addd243bce179d99812309c3f9bb1b7412
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 16:42:20 2022 +0300

    Maybe fix upload-conan-recipes

commit 8ff27ec486c4176676d3c186dfda13e652fb0344
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 15:39:37 2022 +0300

    Check subprocess return in conan_export.py

commit 5652549b863232f573e18c71844323e3298bf080
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 15:22:30 2022 +0300

    Fix bamboo spec

commit 28ae435a1500afd0e288c33695003f9feb59100f
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 15:20:16 2022 +0300

    Get rid of version.h, use increment_version.sh from native_libs_common

commit 01f4f4892d3718ee48e25192259239c6e95183cd
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 15:16:02 2022 +0300

    Fix conandata.yml

commit b4163a3dfdbdd5dc2817988a8325d21754165e83
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 15:10:30 2022 +0300

    Simplify conan export script

commit 03343cd1ae47a1e60fddb09e58bacf498f765991
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 14:57:26 2022 +0300

    Fix bamboo spec

commit 9ba118b74ddc41e1ccd3d7c754120e03e86699ee
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 14:56:19 2022 +0300

    Update changelog

commit ce1c14cdcf18ab1032d12555db1efaa177ef6101
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 14:55:36 2022 +0300

    Fix increment_version.sh and increment version

commit 56186e50fd51925f6fb7dc17e9d1fc7a5831a2c8
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 14:53:19 2022 +0300

    Add versioning system from native_libs_common

commit e6570a1afdda8da0afad51c94e8d1b7375739fea
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 14:20:13 2022 +0300

    Add missing includes

commit 5e708c71553f31e7998dcc5d310e1abecef44ab4
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 14:17:52 2022 +0300

    Add license

commit 09ee4698adc2514a23962f0549f9a571d40f4f96
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 13:30:12 2022 +0300

    Pull variable out of namespace ag

commit 7bfc263756c175c6ac85fd8310c387c666a5038b
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 12:25:21 2022 +0300

    Update native_libs_common to 2.0.10

commit 68025494e7c781cdfd8ee1f4ef801014c8179d67
Author: Nikita Gorskikh <n.gorskikh@adguard.com>
Date:   Mon Aug 1 12:25:05 2022 +0300

    Permanently add /Oy- and -fno-omit-frame-pointer compiler flags

... and 123 more commits
2022-08-03 13:13:43 +03:00

53 lines
1.3 KiB
C++

#pragma once
#include <cstdlib>
#include <optional>
#include <string>
#include "vpn/internal/utils.h"
namespace ag {
struct BufferPeekResult {
std::optional<std::string> err; // nullopt if successful, some error description otherwise
U8View data; // peeked data chunk
};
class DataBuffer {
public:
DataBuffer() = default;
virtual ~DataBuffer() = default;
/**
* Initialize buffer
* @return nullopt if successful, some error description otherwise
*/
virtual std::optional<std::string> init() = 0;
/**
* Get current buffer size
*/
virtual size_t size() const = 0;
/**
* Push data chunk in buffer
* @return nullopt if successful, some error description otherwise
*/
virtual std::optional<std::string> push(U8View data) = 0;
virtual std::optional<std::string> push(std::vector<uint8_t> data) = 0;
/**
* Peek data chunk from buffer (may be less than the buffer size).
* The next call of `peek` returns the same chunk, call to `drain` to advance the buffer.
*/
virtual BufferPeekResult peek() = 0;
/**
* Remove data from buffer
* @param length data length to remove
*/
virtual void drain(size_t length) = 0;
};
} // namespace ag