lib/storage: add abstract storage class

This commit is contained in:
jj 2025-04-30 17:21:22 +00:00
parent e0ced00806
commit dd507e1dcd
No known key found for this signature in database
2 changed files with 19 additions and 1 deletions

View File

@ -1,11 +1,14 @@
import { AbstractStorage } from "./storage";
const COBALT_PROCESSING_DIR = "cobalt-processing-data";
export class OPFSStorage {
export class OPFSStorage extends AbstractStorage {
#root;
#handle;
#io;
constructor(root: FileSystemDirectoryHandle, handle: FileSystemFileHandle, reader: FileSystemSyncAccessHandle) {
super();
this.#root = root;
this.#handle = handle;
this.#io = reader;

View File

@ -0,0 +1,15 @@
export abstract class AbstractStorage {
static init(): Promise<AbstractStorage> {
throw "init() call on abstract implementation";
}
static isAvailable(): boolean {
return false;
}
abstract res(): Promise<File>;
abstract read(size: number, offset: number): Uint8Array;
abstract write(data: Uint8Array | Int8Array, offset: number): Promise<number>;
abstract destroy(): Promise<void>;
};