25 lines
840 B
TypeScript
25 lines
840 B
TypeScript
import * as S from '../gen/sturdy.js';
|
|
import * as IO from '../gen/protocol.js';
|
|
import { Ref } from '../runtime/actor.js';
|
|
import { Decoder, DecoderState, Encoder, EncoderState, GenericPointer, neverPointerType, PointerType, Value } from '@preserves/core';
|
|
|
|
export type WireSymbol = { oid: IO.Oid, ref: Ref, count: number };
|
|
|
|
export const wireRefPointerType: PointerType<S.WireRef> = {
|
|
decode(s: DecoderState): S.WireRef {
|
|
return S.asWireRef(new Decoder<any>(s).next());
|
|
},
|
|
|
|
encode(s: EncoderState, v: S.WireRef): void {
|
|
new Encoder<any>(s, neverPointerType).push(S.fromWireRef(v));
|
|
},
|
|
|
|
fromValue(v: Value<GenericPointer>): S.WireRef {
|
|
return S.asWireRef(v as S._val);
|
|
},
|
|
|
|
toValue(v: S.WireRef): Value<GenericPointer> {
|
|
return S.fromWireRef(v) as Value<GenericPointer>;
|
|
}
|
|
};
|