// THIS FILE IS AUTO GENERATED, DON"T EDIT IT DIRECTLY.
import {
  async_once,

  PrepareCall,
  NanoEventHelper,
  JSON2GrpcMessage,
  DefaultDialHelper
} from '@nanoapp/proxy'

let permissions = [
];

import { grpc } from "@improbable-eng/grpc-web";

import { progInfos as proxyApps } from '@nanoapp/proxy/dist/proginfo.js';

import linux_amd64_224883f782a770df33e3fb58b9b38ab6 from 'file-loader?name=[md5:hash:hex]&&outputPath=nanoapps/linux/amd64/NAPIs/!../../napi.bin/linux/amd64.nanoapp';

import linux_arm64_2c11a38d8a21456b2ada6b3f0bdbd534 from 'file-loader?name=[md5:hash:hex]&&outputPath=nanoapps/linux/arm64/NAPIs/!../../napi.bin/linux/arm64.nanoapp';

let __nprogs__ = {

    "linux/amd64": {
      path: linux_amd64_224883f782a770df33e3fb58b9b38ab6,
      hash: "224883f782a770df33e3fb58b9b38ab6",
      size: "3698724",
    },

    "linux/arm64": {
      path: linux_arm64_2c11a38d8a21456b2ada6b3f0bdbd534,
      hash: "2c11a38d8a21456b2ada6b3f0bdbd534",
      size: "9568256",
    },

}

import { FilesystemClient as _FilesystemClient } from "./filesystem_pb_service.js";

export class Filesystem {
  constructor(dialHelper=DefaultDialHelper) {
    this.__dial_helper = dialHelper
    if (typeof this.__dial_helper.set_nproxy_programs === "function") {
       this.__dial_helper.set_nproxy_programs(proxyApps)
    }
    
  }
  async __dial__() {
    return await this.__dial_helper.dial({
      name: "nanoapp.nstd",
      type: "",


      programs: __nprogs__,

      appclient: _FilesystemClient,
      permissions,
    });
  }
  async Stat(req, scontrol) {
    req = JSON2GrpcMessage(req, Path) 
    let prepare = new PrepareCall(scontrol);
    let thisApp = await this.__dial__();
    if (prepare.shouldReturn()) {
      return
    }
    return new Promise(function(resolve, reject) {
      let ret = thisApp.stat(req, thisApp.options.metadata, (err, msg) => {
        if (err) { reject(err) } else { resolve(msg) }
      })
      prepare.switchToApp(ret, Path)
    })
  }
}

// 导入所有的Message Type
import { Path, Time, FileInfo } from "./filesystem_pb.js";
export { Path, Time, FileInfo }
