Skip to main content
Module

x/earthstar/src/entries/universal.ts>IReplicaAttachmentDriver

Storage for private, distributed, offline-first applications.
Go to Latest
interface IReplicaAttachmentDriver
Re-export
import { type IReplicaAttachmentDriver } from "https://deno.land/x/earthstar@v10.0.2/src/entries/universal.ts";

An attachment driver provides low-level access to a replica's attachments. ReplicaAttachmentDrivers are not meant to be used directly by users; let the Replica talk to it for you.

Methods

getAttachment(formatName: string, attachmentHash: string): Promise<DocAttachment | undefined>

Returns an attachment for a given format and hash.

stage(formatName: string, attachment: Uint8Array | ReadableStream<Uint8Array>): Promise<{ hash: string; size: number; commit: () => Promise<void>; reject: () => Promise<void>; } | ValidationError>

Upserts the attachment to a staging area, and returns an object used to assess whether it is what we're expecting.

erase(formatName: string, attachmentHash: string): Promise<true | ValidationError>

Erases an attachment for a given format and hash.

wipe(): Promise<void>

Erase all stored attachments

filter(attachments: Record<string, Set<string>>): Promise<{ format: string; hash: string; }[]>

Delete all stored attachments not included in the provided list of hashes and their formats.

clearStaging(): Promise<void>

Reject all attachments waiting in staging.

close(erase: boolean): Promise<void>

Close the replica Driver. The replica will call this. You cannot call close() if the replica is already closed (it will throw a ReplicaIsClosedError). If erase, actually delete and forget data locally. Erase defaults to false if not provided.

isClosed(): boolean

Returns if the attachment driver has been closed or not.