import { Milliseconds } from "." ; import { Deferral } from "./deferral" ; import { Dispatchable , LocalTemporaryRef , Ref } from "./references" ; export interface ICanDispatch < Msg , DispatchResult = void > { dispatch ( msg ) : DispatchResult ; } export type QueryMsgFactory < Req , Res > = ( tempRef : Dispatchable < Res > ) => Req ; export type InferResponseFromMsgFactory < T extends QueryMsgFactory < any , any > > = T extends QueryMsgFactory < infer _Req , infer Res > ? Res : never ; export interface ICanQuery < Msg > { query < MsgFactory extends QueryMsgFactory < Msg , any > > ( msgFactory , timeout ) : Promise < InferResponseFromMsgFactory < MsgFactory > > ; } export interface ICanStop < StopResult = void > { stop ( ) : StopResult ; } export interface ICanManageTempReferences { addTempReference ( reference , deferral ) : void ; removeTempReference ( reference ) : void ; } export interface ICanReset { reset ( ) : void ; } export interface ICanFind { find ( path ) : any | undefined ; } export interface IHaveChildren < Child , System > { children : Map < string , Child > ; system : System ; childStopped ( child ) : void ; childSpawned ( child ) : void ; } export type IHaveName = { name : string ; reference : Ref ; } ; export interface ICanHandleFault < Child extends ICanStop & ICanReset & IHaveName > { handleFault ( msg , error , child ? ) : Promise < void > | void ; } export interface ICanAssertNotStopped { assertNotStopped ( ) : boolean ; }