mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 01:18:27 +00:00
lib/storage: add abstract storage class
This commit is contained in:
parent
e0ced00806
commit
dd507e1dcd
@ -1,11 +1,14 @@
|
|||||||
|
import { AbstractStorage } from "./storage";
|
||||||
|
|
||||||
const COBALT_PROCESSING_DIR = "cobalt-processing-data";
|
const COBALT_PROCESSING_DIR = "cobalt-processing-data";
|
||||||
|
|
||||||
export class OPFSStorage {
|
export class OPFSStorage extends AbstractStorage {
|
||||||
#root;
|
#root;
|
||||||
#handle;
|
#handle;
|
||||||
#io;
|
#io;
|
||||||
|
|
||||||
constructor(root: FileSystemDirectoryHandle, handle: FileSystemFileHandle, reader: FileSystemSyncAccessHandle) {
|
constructor(root: FileSystemDirectoryHandle, handle: FileSystemFileHandle, reader: FileSystemSyncAccessHandle) {
|
||||||
|
super();
|
||||||
this.#root = root;
|
this.#root = root;
|
||||||
this.#handle = handle;
|
this.#handle = handle;
|
||||||
this.#io = reader;
|
this.#io = reader;
|
||||||
|
15
web/src/lib/storage/storage.ts
Normal file
15
web/src/lib/storage/storage.ts
Normal 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>;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user