// Generated by bynkc — do not edit by hand.
// context app.b

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

export const whoami = {
  async call(ping: string, deps: { identity: string }): Promise<Result<string, string>> {
    return Ok(deps.identity);
  },
};

export function serialise_Result_String_String(value: Result<string, string>): JsonValue {
  if (value.tag === "Ok") return { kind: "Ok", value: value.value as JsonValue };
  return { kind: "Err", error: value.error as JsonValue };
}

export function deserialise_Result_String_String(json: JsonValue, path: string = "$"): Result<Result<string, string>, 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 (obj["kind"] === "Ok") {
  if (typeof obj["value"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.value`, expected: "string", actual: typeof obj["value"] });
  }
  const __v = obj["value"];
    return Ok(Ok(__v) as Result<string, string>);
  } else if (obj["kind"] === "Err") {
  if (typeof obj["error"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.error`, expected: "string", actual: typeof obj["error"] });
  }
  const __e = obj["error"];
    return Ok(Err(__e) as Result<string, string>);
  }
  return Err({ kind: "StructuralMismatch", path, expected: "Ok | Err", actual: String(obj["kind"]) });
}

