// Generated by bynkc — do not edit by hand.
// context mailer

import { Ok, Err, Some, None, type Result, type Option, type ValidationError, QueueResult, type JsonValue, type BoundaryError, type ServiceBinding, callService, boundaryError } from "../../runtime.js";

export interface EmailJob {
  readonly to: string;
  readonly subject: string;
}

export const EmailJob = {
};

export const outbox = {
  async queue_outbox_0(message: EmailJob, deps: {}): Promise<QueueResult> {
    return QueueResult.Ack;
  },
};

export function serialise_EmailJob(value: EmailJob): JsonValue {
  return {
    to: value.to as JsonValue,
    subject: value.subject as JsonValue,
  };
}

export function deserialise_EmailJob(json: JsonValue, path: string = "$"): Result<EmailJob, BoundaryError> {
  if (typeof json !== "object" || json === null || Array.isArray(json)) {
    return Err({ kind: "StructuralMismatch", path, expected: "object", actual: typeof json });
  }
  const obj = json as { [k: string]: JsonValue };
  if (typeof obj["to"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.to`, expected: "string", actual: typeof obj["to"] });
  }
  const __to = obj["to"];
  if (typeof obj["subject"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.subject`, expected: "string", actual: typeof obj["subject"] });
  }
  const __subject = obj["subject"];
  return Ok({ to: __to, subject: __subject } as EmailJob);
}


