32 *
this = std::move(
other);
38 owned_storage_ = std::move(
other.owned_storage_);
44 other.mapped_ =
nullptr;
45 other.mapped_size_ = 0;
47 other.data_ =
nullptr;
64 const std::filesystem::path&
path
66 auto buffer = std::make_unique<FastxFileBuffer>();
73 return std::string_view{data_, size_};
82 std::vector<char> owned_storage_;
83 const char* data_{
nullptr};
99 owned_storage_.clear();
104 [[
nodiscard]] Result<void> load_from_path(
const std::filesystem::path&
path) {
107#if defined(__linux__)
133 data_ =
static_cast<const char*
>(
mapped_);
139 if (!
input.is_open()) {
142 input.seekg(0, std::ios::end);
147 owned_storage_.resize(
static_cast<size_t>(
file_size));
148 input.seekg(0, std::ios::beg);
149 if (!owned_storage_.empty()) {
150 input.read(owned_storage_.data(),
static_cast<std::streamsize
>(owned_storage_.size()));
157 data_ = owned_storage_.data();
158 size_ = owned_storage_.size();
Read-only contiguous file payload for in-memory FASTX parsing.
FastxFileBuffer & operator=(FastxFileBuffer &&other) noexcept
FastxFileBuffer(FastxFileBuffer &&other) noexcept
static Result< std::unique_ptr< FastxFileBuffer > > load(const std::filesystem::path &path)
Loads an uncompressed file via mmap (Linux) or read into memory.
FastxFileBuffer()=default
bool empty() const noexcept
True when the file is empty or load produced no bytes.
FastxFileBuffer(const FastxFileBuffer &)=delete
std::string_view data() const noexcept
Contiguous read-only file bytes.
FastxFileBuffer & operator=(const FastxFileBuffer &)=delete
#define CUSBF_TRY(expr)
Propagates a cusbf::Result failure from the enclosing function (GNU statement expression).
bool isGzipFile(const std::filesystem::path &path)
True when path begins with the gzip magic bytes (0x1F, 0x8B).
bool fastx_file_supports_memory_map(const std::filesystem::path &path)
True when path is not gzip-compressed (mmap path is usable).
consteval bool separatorPositionAlwaysEncodesInvalid(char *input, uint64_t separatorPosition, uint64_t index)
Recursively tests whether placing the separator byte at any position in an input of valid bytes alway...
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
static Error io(std::string message)
Fallible API result: cuda::std::expected<T, Error> with cuSBF factories.