// package: lnks.nstd
// file: filesystem.proto

import * as filesystem_pb from "./filesystem_pb";
import {grpc} from "@improbable-eng/grpc-web";

type FilesystemStat = {
  readonly methodName: string;
  readonly service: typeof Filesystem;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof filesystem_pb.Path;
  readonly responseType: typeof filesystem_pb.FileInfo;
};

type FilesystemMkdir = {
  readonly methodName: string;
  readonly service: typeof Filesystem;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof filesystem_pb.MkdirRequest;
  readonly responseType: typeof filesystem_pb.Path;
};

type FilesystemRmdir = {
  readonly methodName: string;
  readonly service: typeof Filesystem;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof filesystem_pb.RmdirRequest;
  readonly responseType: typeof filesystem_pb.Path;
};

export class Filesystem {
  static readonly serviceName: string;
  static readonly Stat: FilesystemStat;
  static readonly Mkdir: FilesystemMkdir;
  static readonly Rmdir: FilesystemRmdir;
}

export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
export type Status = { details: string, code: number; metadata: grpc.Metadata }

interface UnaryResponse {
  cancel(): void;
}
interface ResponseStream<T> {
  cancel(): void;
  on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
  on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
  on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
}
interface RequestStream<T> {
  write(message: T): RequestStream<T>;
  end(): void;
  cancel(): void;
  on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
  on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
}
interface BidirectionalStream<ReqT, ResT> {
  write(message: ReqT): BidirectionalStream<ReqT, ResT>;
  end(): void;
  cancel(): void;
  on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
}

export class FilesystemClient {
  readonly serviceHost: string;

  constructor(serviceHost: string, options?: grpc.RpcOptions);
  stat(
    requestMessage: filesystem_pb.Path,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: filesystem_pb.FileInfo|null) => void
  ): UnaryResponse;
  stat(
    requestMessage: filesystem_pb.Path,
    callback: (error: ServiceError|null, responseMessage: filesystem_pb.FileInfo|null) => void
  ): UnaryResponse;
  mkdir(
    requestMessage: filesystem_pb.MkdirRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: filesystem_pb.Path|null) => void
  ): UnaryResponse;
  mkdir(
    requestMessage: filesystem_pb.MkdirRequest,
    callback: (error: ServiceError|null, responseMessage: filesystem_pb.Path|null) => void
  ): UnaryResponse;
  rmdir(
    requestMessage: filesystem_pb.RmdirRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: filesystem_pb.Path|null) => void
  ): UnaryResponse;
  rmdir(
    requestMessage: filesystem_pb.RmdirRequest,
    callback: (error: ServiceError|null, responseMessage: filesystem_pb.Path|null) => void
  ): UnaryResponse;
}

