1+ import { SerdeContext } from "@smithy/core/protocols" ;
12import { NormalizedSchema } from "@smithy/core/schema" ;
23import { _parseEpochTimestamp , generateIdempotencyToken } from "@smithy/core/serde" ;
3- import type { Codec , Schema , SerdeFunctions , ShapeDeserializer , ShapeSerializer } from "@smithy/types" ;
4+ import type { Codec , Schema , ShapeDeserializer , ShapeSerializer } from "@smithy/types" ;
45import { fromBase64 } from "@smithy/util-base64" ;
56
67import { cbor } from "./cbor" ;
@@ -9,9 +10,7 @@ import { dateToTag } from "./parseCborBody";
910/**
1011 * @alpha
1112 */
12- export class CborCodec implements Codec < Uint8Array , Uint8Array > {
13- private serdeContext ?: SerdeFunctions ;
14-
13+ export class CborCodec extends SerdeContext implements Codec < Uint8Array , Uint8Array > {
1514 public createSerializer ( ) : CborShapeSerializer {
1615 const serializer = new CborShapeSerializer ( ) ;
1716 serializer . setSerdeContext ( this . serdeContext ! ) ;
@@ -23,23 +22,14 @@ export class CborCodec implements Codec<Uint8Array, Uint8Array> {
2322 deserializer . setSerdeContext ( this . serdeContext ! ) ;
2423 return deserializer ;
2524 }
26-
27- public setSerdeContext ( serdeContext : SerdeFunctions ) : void {
28- this . serdeContext = serdeContext ;
29- }
3025}
3126
3227/**
3328 * @alpha
3429 */
35- export class CborShapeSerializer implements ShapeSerializer {
36- private serdeContext ?: SerdeFunctions ;
30+ export class CborShapeSerializer extends SerdeContext implements ShapeSerializer {
3731 private value : unknown ;
3832
39- public setSerdeContext ( serdeContext : SerdeFunctions ) {
40- this . serdeContext = serdeContext ;
41- }
42-
4333 public write ( schema : Schema , value : unknown ) : void {
4434 this . value = this . serialize ( schema , value ) ;
4535 }
@@ -127,13 +117,7 @@ export class CborShapeSerializer implements ShapeSerializer {
127117/**
128118 * @alpha
129119 */
130- export class CborShapeDeserializer implements ShapeDeserializer {
131- private serdeContext ?: SerdeFunctions ;
132-
133- public setSerdeContext ( serdeContext : SerdeFunctions ) {
134- this . serdeContext = serdeContext ;
135- }
136-
120+ export class CborShapeDeserializer extends SerdeContext implements ShapeDeserializer {
137121 public read ( schema : Schema , bytes : Uint8Array ) : any {
138122 const data : any = cbor . deserialize ( bytes ) ;
139123 return this . readValue ( schema , data ) ;
0 commit comments