github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/daemon/internal/api/api.go (about)

     1  // Package api defines types and constants useful for the API between the daemon
     2  // service and client.
     3  package api
     4  
     5  import (
     6  	"github.com/markusbkk/elvish/pkg/store/storedefs"
     7  )
     8  
     9  // Version is the API version. It should be bumped any time the API changes.
    10  const Version = -93
    11  
    12  // ServiceName is the name of the RPC service exposed by the daemon.
    13  const ServiceName = "Daemon"
    14  
    15  // Basic requests.
    16  
    17  type VersionRequest struct{}
    18  
    19  type VersionResponse struct {
    20  	Version int
    21  }
    22  
    23  type PidRequest struct{}
    24  
    25  type PidResponse struct {
    26  	Pid int
    27  }
    28  
    29  // Cmd requests.
    30  
    31  type NextCmdSeqRequest struct{}
    32  
    33  type NextCmdSeqResponse struct {
    34  	Seq int
    35  }
    36  
    37  type AddCmdRequest struct {
    38  	Text string
    39  }
    40  
    41  type AddCmdResponse struct {
    42  	Seq int
    43  }
    44  
    45  type DelCmdRequest struct {
    46  	Seq int
    47  }
    48  
    49  type DelCmdResponse struct {
    50  }
    51  
    52  type CmdRequest struct {
    53  	Seq int
    54  }
    55  
    56  type CmdResponse struct {
    57  	Text string
    58  }
    59  
    60  type CmdsRequest struct {
    61  	From int
    62  	Upto int
    63  }
    64  
    65  type CmdsResponse struct {
    66  	Cmds []string
    67  }
    68  
    69  type CmdsWithSeqRequest struct {
    70  	From int
    71  	Upto int
    72  }
    73  
    74  type CmdsWithSeqResponse struct {
    75  	Cmds []storedefs.Cmd
    76  }
    77  
    78  type NextCmdRequest struct {
    79  	From   int
    80  	Prefix string
    81  }
    82  
    83  type NextCmdResponse struct {
    84  	Seq  int
    85  	Text string
    86  }
    87  
    88  type PrevCmdRequest struct {
    89  	Upto   int
    90  	Prefix string
    91  }
    92  
    93  type PrevCmdResponse struct {
    94  	Seq  int
    95  	Text string
    96  }
    97  
    98  // Dir requests.
    99  
   100  type AddDirRequest struct {
   101  	Dir       string
   102  	IncFactor float64
   103  }
   104  
   105  type AddDirResponse struct{}
   106  
   107  type DelDirRequest struct {
   108  	Dir string
   109  }
   110  
   111  type DelDirResponse struct{}
   112  
   113  type DirsRequest struct {
   114  	Blacklist map[string]struct{}
   115  }
   116  
   117  type DirsResponse struct {
   118  	Dirs []storedefs.Dir
   119  }
   120  
   121  // SharedVar requests.
   122  
   123  type SharedVarRequest struct {
   124  	Name string
   125  }
   126  
   127  type SharedVarResponse struct {
   128  	Value string
   129  }
   130  
   131  type SetSharedVarRequest struct {
   132  	Name  string
   133  	Value string
   134  }
   135  
   136  type SetSharedVarResponse struct{}
   137  
   138  type DelSharedVarRequest struct {
   139  	Name string
   140  }
   141  
   142  type DelSharedVarResponse struct{}