Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
atomic_publisher.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <cstdint>
6#include <filesystem>
7#include <memory>
8#include <span>
9#include <string>
10#include <string_view>
11
13
26
34
45
52 public:
55 create(const std::filesystem::path& destination) noexcept;
58 create_file(const std::filesystem::path& destination) noexcept;
59
62 AtomicPublisher& operator=(AtomicPublisher&&) noexcept;
64 AtomicPublisher& operator=(const AtomicPublisher&) = delete;
65
68 const std::filesystem::path& staging_directory() const noexcept;
71 const std::filesystem::path& staging_file() const noexcept;
73 runtime::Result<bool, PackageError> write(std::string_view relative_utf8,
74 std::span<const std::uint8_t> bytes) noexcept;
76 runtime::Result<bool, PackageError> write(std::string_view relative_utf8,
77 std::string_view text) noexcept;
82 commit_file(const std::filesystem::path& staged_file) noexcept;
89 void cancel() noexcept;
90
91 private:
92 struct Impl;
93 static runtime::Result<AtomicPublisher, PackageError>
94 create_impl(const std::filesystem::path& destination, bool file) noexcept;
95 explicit AtomicPublisher(std::unique_ptr<Impl> impl) noexcept;
96 std::unique_ptr<Impl> impl_;
97};
98
99} // namespace pulp::project_package
runtime::Result< bool, PackageError > write(std::string_view relative_utf8, std::span< const std::uint8_t > bytes) noexcept
Writes and durably fences one lexically safe relative file.
const std::filesystem::path & staging_file() const noexcept
Returns the pre-created private file slot for a file publication.
static runtime::Result< AtomicPublisher, PackageError > create_file(const std::filesystem::path &destination) noexcept
Creates a private, pre-permissioned file slot for one external writer.
void cancel() noexcept
Removes unpublished staging on a best-effort basis.
const std::filesystem::path & staging_directory() const noexcept
Returns the private root for a directory publication.
AtomicPublisher(AtomicPublisher &&) noexcept
runtime::Result< AtomicPublishOutcome, PackageError > commit_file(const std::filesystem::path &staged_file) noexcept
Publishes the pre-created staging_file() at the destination.
runtime::Result< AtomicPublishOutcome, PackageError > commit_directory() noexcept
Publishes the complete staged tree without replacing an existing path.
static runtime::Result< AtomicPublisher, PackageError > create(const std::filesystem::path &destination) noexcept
Creates a private staging sibling for a destination that must not exist.
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
Definition atomic_publisher.hpp:12
PackageErrorCode
Stable failure categories for package layout and publication operations.
Definition atomic_publisher.hpp:15
@ AlreadyOpen
Definition atomic_publisher.hpp:18
@ InvalidLayout
Definition atomic_publisher.hpp:17
@ HashMismatch
Definition atomic_publisher.hpp:19
@ LimitExceeded
Definition atomic_publisher.hpp:24
@ DurabilityUncertain
Definition atomic_publisher.hpp:22
@ InvalidPath
Definition atomic_publisher.hpp:16
@ PublicationConflict
Definition atomic_publisher.hpp:21
@ InvalidGeneration
Definition atomic_publisher.hpp:23
@ IoError
Definition atomic_publisher.hpp:20
AtomicPublishOutcome
Visibility and finalization state after a namespace-publication attempt.
Definition atomic_publisher.hpp:36
@ PublishedDurabilityUncertain
The destination is visible, but final permission adoption or namespace fencing did not complete.
Definition atomic_publisher.hpp:43
@ NotPublished
The destination name was not published.
Definition atomic_publisher.hpp:38
@ PublishedDurably
The destination has final permissions and its parent namespace was durably fenced.
Definition atomic_publisher.hpp:40
Definition generated_event_source.hpp:33
STL namespace.
Result<T, E> — success / failure union for fallible operations.
Path-bearing package failure.
Definition atomic_publisher.hpp:28
std::filesystem::path path
Path at which the operation failed, when one is available.
Definition atomic_publisher.hpp:32
PackageErrorCode code
Machine-readable failure category.
Definition atomic_publisher.hpp:30