import { EncoderDecoder } from '@iotize/common/converter/api';
import { Observable, Subject } from 'rxjs';
export declare type KeyTypeType = string | number | symbol;
export interface EditableDataStreamInterface<DataType, RawType, KeyType extends KeyTypeType> {
    id: KeyType;
    rawValueSnaphot: RawType | undefined;
    valueSnapshot: DataType | undefined;
    rawValues: Observable<RawType>;
    values: Observable<DataType>;
    readRaw(): Promise<RawType>;
    writeRaw(data: RawType): Promise<void>;
    notifyRawValue(newValue: RawType): void;
    read(): Promise<DataType>;
    write(value: DataType): Promise<any>;
}
export declare type RawBundleType<DataType> = Record<keyof DataType, Uint8Array | undefined>;
export interface BundleDataStreamInterface<DataType extends Record<KeyTypeType, any>> extends EditableDataStreamInterface<DataType, RawBundleType<DataType>, keyof DataType> {
    variables: EditableDataStreamInterface<DataType[keyof DataType], Uint8Array, keyof DataType>[];
    variable(id: keyof DataType): EditableDataStreamInterface<DataType[keyof DataType], Uint8Array, keyof DataType>;
}
export declare abstract class AbstractBundleDataStream<DataType extends Record<KeyTypeType, any>> implements BundleDataStreamInterface<Record<keyof DataType, DataType[keyof DataType]>> {
    private _variables;
    abstract id: KeyTypeType;
    get variables(): EditableDataStreamInterface<DataType[keyof DataType], Uint8Array, keyof DataType>[];
    constructor(_variables: Record<keyof DataType, EditableDataStreamInterface<DataType[keyof DataType], Uint8Array, keyof DataType>>);
    abstract readRawInner(): Promise<RawBundleType<DataType>>;
    readRaw(): Promise<RawBundleType<DataType>>;
    read(): Promise<DataType>;
    write(value: DataType): Promise<void>;
    variable<Key extends keyof DataType>(id: Key): EditableDataStreamInterface<DataType[Key], Uint8Array, Key>;
    get rawValues(): Observable<RawBundleType<DataType>>;
    get rawValueSnaphot(): RawBundleType<DataType>;
    get valueSnapshot(): DataType;
    get values(): Observable<DataType>;
    notifyRawValue(v: RawBundleType<DataType>): Promise<void>;
    findVariable(id: keyof DataType): Record<keyof DataType, EditableDataStreamInterface<DataType[keyof DataType], Uint8Array, keyof DataType>>[keyof DataType] | undefined;
    hasVariable(id: keyof DataType): boolean;
    writeRaw(values: RawBundleType<DataType>): Promise<void>;
}
export declare abstract class AbstractEditableDataStream<DataType, RawType = Uint8Array, KeyType extends KeyTypeType = KeyTypeType> implements EditableDataStreamInterface<DataType, RawType, KeyType> {
    abstract id: KeyType;
    private _lastRawValue?;
    abstract converter: EncoderDecoder<DataType, RawType>;
    get lastRawValue(): RawType | undefined;
    protected rawDataStream: Subject<RawType>;
    readonly values: Observable<DataType>;
    constructor();
    abstract readRawInner(): Promise<RawType>;
    abstract writeRaw(value: RawType): Promise<void>;
    get rawValueSnaphot(): RawType | undefined;
    get valueSnapshot(): DataType | undefined;
    get rawValues(): Observable<RawType>;
    notifyRawValue(newValue: RawType): Promise<void>;
    readRaw(): Promise<RawType>;
    read(): Promise<DataType>;
    write(value: DataType): Promise<any>;
    private encodeValue;
    private decodeValue;
}
