// src/engine/remoting/RequestReplyBinder.ts

import type { IMatrixContext } from '../core/IMatrixContext';
import type { IMethodSpec } from '../reflection/IInterfaceDescriptor';
import { RequestReply } from './RequestReply';

/**
 * Thin adapter for binding RR handlers to a context + mount.
 * Uses RequestReply.bind under the hood; no separate implementation.
 */
export class RequestReplyBinder {
  static bindRR<TReq, TRes>(
    context: IMatrixContext,
    mount: string,
    op: string,
    handler: (params: TReq) => Promise<TRes> | TRes,
    IMethodSpec?: IMethodSpec
  ): () => void {
    return RequestReply.bind<TReq, TRes>(
      context,
      mount,
      op,
      handler,
      IMethodSpec
    );
  }
}

export const bindRR = RequestReplyBinder.bindRR;
