userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
operations_encrypted.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/dump/operations_encrypted.hpp
4
/// @brief Encrypted dump Reader and Writer implementations
5
6
#
include
<
filesystem
>
7
#
include
<
utility
>
8
9
#
include
<
userver
/
dump
/
factory
.
hpp
>
10
#
include
<
userver
/
dump
/
operations
.
hpp
>
11
#
include
<
userver
/
fs
/
blocking
/
impl
/
permissions
.
hpp
>
12
#
include
<
userver
/
utils
/
fast_pimpl
.
hpp
>
13
#
include
<
userver
/
utils
/
strong_typedef
.
hpp
>
14
15
USERVER_NAMESPACE_BEGIN
16
17
namespace
dump
{
18
19
using
SecretKey
=
utils
::
NonLoggable
<
class
SecretKeyTag, std::string>;
20
21
class
EncryptedWriter
final
:
public
Writer
{
22
public
:
23
/// @brief Creates a new dump file and opens it
24
/// @param perms final permissions to set on the dump file
25
/// @throws `Error` on a filesystem error
26
EncryptedWriter
(
27
std::string filename,
28
const
SecretKey& secret_key,
29
std::filesystem::perms perms,
30
tracing::
ScopeTime
& scope
31
);
32
33
/// @overload
34
/// Accepts `boost::filesystem::perms`; permission option flags are ignored.
35
/// @deprecated use the std::filesystem overload
36
template
<
fs
::
blocking
::
impl
::LegacyPermissions Permissions>
37
EncryptedWriter
(std::string filename,
const
SecretKey& secret_key, Permissions perms, tracing::
ScopeTime
& scope)
38
:
dump
::EncryptedWriter(std::move(filename), secret_key, fs::
blocking
::impl::ToStdPermissions(perms), scope)
39
{}
40
41
~EncryptedWriter()
override
;
42
43
void
Finish
()
override
;
44
45
private
:
46
void
WriteRaw(std::string_view data)
override
;
47
48
struct
Impl;
49
utils
::FastPimpl<Impl, 632, 8> impl_;
50
};
51
52
class
EncryptedReader
final
:
public
Reader
{
53
public
:
54
/// @brief Opens an existing dump file
55
/// @throws `Error` on a filesystem error
56
EncryptedReader
(std::string filename,
const
SecretKey& key);
57
58
~EncryptedReader()
override
;
59
60
void
Finish
()
override
;
61
62
private
:
63
std::string_view ReadRaw(std::size_t max_size)
override
;
64
65
void
BackUp(std::size_t size)
override
;
66
67
struct
Impl;
68
utils
::FastPimpl<Impl, 600, 8> impl_;
69
};
70
71
class
EncryptedOperationsFactory
final
:
public
OperationsFactory
{
72
public
:
73
/// @brief Creates a factory that encrypts dumps with the specified key and writes them with the specified
74
/// permissions.
75
EncryptedOperationsFactory
(SecretKey&& secret_key, std::filesystem::perms perms);
76
77
/// @overload
78
/// Accepts `boost::filesystem::perms`; permission option flags are ignored.
79
/// @deprecated use the std::filesystem overload
80
template
<
fs
::
blocking
::
impl
::LegacyPermissions Permissions>
81
EncryptedOperationsFactory
(SecretKey&& secret_key, Permissions perms)
82
:
dump
::EncryptedOperationsFactory(std::move(secret_key), fs::
blocking
::impl::ToStdPermissions(perms))
83
{}
84
85
std::unique_ptr<
Reader
> CreateReader(std::string full_path)
override
;
86
87
std::unique_ptr<
Writer
> CreateWriter(std::string full_path, tracing::
ScopeTime
& scope)
override
;
88
89
private
:
90
const
SecretKey secret_key_;
91
const
std::filesystem::perms perms_;
92
};
93
94
}
// namespace dump
95
96
USERVER_NAMESPACE_END
userver
dump
operations_encrypted.hpp
Generated on
for userver by
Doxygen
1.17.0