Public Access
GeminiService fetches on a short-lived task and hands the App a GeminiPage: header, the body as lines in 4 KB chunks (TextBuffer: no large block, no doubling copies), the final URL after up to 5 redirects. Certificates are pinned on first use per host and port; a change comes back as its own outcome with both fingerprints. No fetch starts below 55 KB free (Q86). With a card, the body streams to /gemini/cache/page.gmi in 1 KB pieces while the connection is open, then loads into RAM once its memory is back (Q87); StorageService::runAndWait (moved from the Debug Console) keeps every card access on the storage task. Without a card: RAM, with the steady and transient floors. Measured with IRC connected: Cosmos (31.6 KB) went from 4.6 KB to the whole page on the card and 20 KB on screen; lowest free heap 19.5 KB in transfer, 43 KB once loaded. `gemini get` and `gemini trust` on the console. 14 Gemini tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace roro::gemini {
|
|
|
|
// A page's text, kept as lines in 4 KB chunks: no large contiguous block (with IRC connected the
|
|
// largest free block is about 31 KB) and no copy when it grows. About 4 bytes per line on top of
|
|
// the text itself. Bytes are fed as they arrive; lines end at LF, a CR before it is dropped.
|
|
class TextBuffer {
|
|
public:
|
|
static constexpr size_t kChunk = 4096;
|
|
|
|
void append(const char* data, size_t len);
|
|
void finish(); // the last line, if it has no line end
|
|
size_t lineCount() const { return lines_.size(); }
|
|
std::string line(size_t i) const;
|
|
size_t bytes() const { return bytes_; }
|
|
void clear();
|
|
|
|
private:
|
|
struct Ref {
|
|
uint16_t chunk;
|
|
uint16_t offset;
|
|
uint16_t length;
|
|
};
|
|
void endLine();
|
|
|
|
std::vector<std::string> chunks_;
|
|
std::vector<Ref> lines_;
|
|
std::string partial_; // the line being received
|
|
size_t bytes_ = 0;
|
|
};
|
|
|
|
} // namespace roro::gemini
|