Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
archive.hpp
Go to the documentation of this file.
1#pragma once
2
10
14
15#include <cstdint>
16#include <filesystem>
17#include <memory>
18#include <optional>
19#include <span>
20#include <string>
21#include <string_view>
22#include <vector>
23
25
26struct MemberInfo {
27 std::string path;
28 std::uint64_t compressed_bytes = 0;
29 std::uint64_t expanded_bytes = 0;
31 std::uint16_t method = 0;
32};
33
38public:
40 CapsuleArchive& operator=(CapsuleArchive&&) noexcept;
42 CapsuleArchive& operator=(const CapsuleArchive&) = delete;
44
46 std::span<const MemberInfo> members() const noexcept;
47
50 std::span<const std::uint8_t> manifest_bytes() const noexcept;
51
54 runtime::Result<std::vector<std::uint8_t>, CapsuleError> read(std::string_view path) const;
55
58 std::uint64_t peak_bytes() const noexcept;
59
60private:
61 struct Impl;
62 explicit CapsuleArchive(std::unique_ptr<Impl> impl);
63 std::unique_ptr<Impl> impl_;
64
65 friend runtime::Result<CapsuleArchive, CapsuleError>
66 open_archive(const std::filesystem::path&, const CapsuleLimits&);
67};
68
70open_archive(const std::filesystem::path& path, const CapsuleLimits& limits = kCapsuleLimitsV1);
71
74 std::string path;
75 std::vector<std::uint8_t> bytes;
76};
77
84write_archive_no_replace(const std::vector<WriteMember>& members,
85 const std::filesystem::path& destination,
86 const CapsuleLimits& limits = kCapsuleLimitsV1);
87
88} // namespace pulp::authoring_capsule
friend runtime::Result< CapsuleArchive, CapsuleError > open_archive(const std::filesystem::path &, const CapsuleLimits &)
std::span< const MemberInfo > members() const noexcept
Members in archive order. The manifest is always index 0.
std::span< const std::uint8_t > manifest_bytes() const noexcept
The bounded root manifest bytes.
std::uint64_t peak_bytes() const noexcept
Peak bytes charged so far.
CapsuleArchive(CapsuleArchive &&) noexcept
runtime::Result< std::vector< std::uint8_t >, CapsuleError > read(std::string_view path) const
Expand one member.
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
Archive and path budgets.
Definition archive.hpp:24
constexpr CapsuleLimits kCapsuleLimitsV1
The frozen v1 budgets.
Definition limits.hpp:35
runtime::Result< std::uint64_t, CapsuleError > write_archive_no_replace(const std::vector< WriteMember > &members, const std::filesystem::path &destination, const CapsuleLimits &limits=kCapsuleLimitsV1)
Write deterministically to a path that must not already exist.
runtime::Result< CapsuleArchive, CapsuleError > open_archive(const std::filesystem::path &path, const CapsuleLimits &limits=kCapsuleLimitsV1)
Definition generated_event_source.hpp:33
STL namespace.
Result<T, E> — success / failure union for fallible operations.
Admission failure vocabulary for authoring capsules.
A rejection with the exact subject that caused it.
Definition status.hpp:69
Definition archive.hpp:26
std::string path
Definition archive.hpp:27
std::uint64_t compressed_bytes
Definition archive.hpp:28
std::uint64_t expanded_bytes
Definition archive.hpp:29
std::uint16_t method
Store (0) or deflate (8). Any other method is unsafe_archive.
Definition archive.hpp:31
One member to write. path must already be normalized.
Definition archive.hpp:73
std::string path
Definition archive.hpp:74
std::vector< std::uint8_t > bytes
Definition archive.hpp:75