/** * @since 4.0.0 */ import { identity } from "./Function.ts" import * as Schema from "./Schema.ts" import * as Transformation from "./SchemaTransformation.ts" /** * @since 4.0.0 * @experimental */ export function getNativeClassSchema any, S extends Schema.Struct>( constructor: C, options: { readonly encoding: S readonly annotations?: Schema.Annotations.Declaration> } ): Schema.decodeTo, S["Iso"]>, S> { const transformation = Transformation.transform, S["Type"]>({ decode: (props) => new constructor(props), encode: identity }) return Schema.instanceOf(constructor, { toCodec: () => Schema.link>()(options.encoding, transformation), ...options.annotations }).pipe(Schema.encodeTo(options.encoding, transformation)) }