diff --git a/cli/daemon/daemon.go b/cli/daemon/daemon.go index 489c36d7edf..56bb6524edf 100644 --- a/cli/daemon/daemon.go +++ b/cli/daemon/daemon.go @@ -33,6 +33,7 @@ import ( "github.com/arduino/arduino-cli/metrics" srv_commands "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" srv_debug "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1" + srv_files "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1" srv_monitor "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/monitor/v1" srv_settings "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1" "github.com/segmentio/stats/v4" @@ -98,6 +99,9 @@ func runDaemonCommand(cmd *cobra.Command, args []string) { // Register the debug session service srv_debug.RegisterDebugServiceServer(s, &daemon.DebugService{}) + // Register the files service + srv_files.RegisterFilesServiceServer(s, &daemon.FilesService{}) + if !daemonize { // When parent process ends terminate also the daemon go func() { diff --git a/commands/daemon/files.go b/commands/daemon/files.go new file mode 100644 index 00000000000..b9d662daafc --- /dev/null +++ b/commands/daemon/files.go @@ -0,0 +1,42 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package daemon + +import ( + "context" + "os" + + rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1" +) + +// FilesService implements the `Files` service +type FilesService struct { + rpc.UnimplementedFilesServiceServer +} + +// LoadFile returns a requested file content or an error. +func (s *FilesService) LoadFile(ctx context.Context, req *rpc.LoadFileRequest) (*rpc.LoadFileResponse, error) { + content, err := os.ReadFile(req.Path) + // TODO: support req.Type other than RAW or remove Type from .proto + if err == nil { + return &rpc.LoadFileResponse{ + Content: content, + Type: rpc.ContentType_CONTENT_TYPE_RAW_UNSPECIFIED, + }, nil + } + + return nil, err +} diff --git a/rpc/cc/arduino/cli/files/v1/files.pb.go b/rpc/cc/arduino/cli/files/v1/files.pb.go new file mode 100644 index 00000000000..7338eb3b77b --- /dev/null +++ b/rpc/cc/arduino/cli/files/v1/files.pb.go @@ -0,0 +1,317 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: cc/arduino/cli/files/v1/files.proto + +package files + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ContentType int32 + +const ( + ContentType_CONTENT_TYPE_RAW_UNSPECIFIED ContentType = 0 + ContentType_CONTENT_TYPE_ZIP ContentType = 1 +) + +// Enum value maps for ContentType. +var ( + ContentType_name = map[int32]string{ + 0: "CONTENT_TYPE_RAW_UNSPECIFIED", + 1: "CONTENT_TYPE_ZIP", + } + ContentType_value = map[string]int32{ + "CONTENT_TYPE_RAW_UNSPECIFIED": 0, + "CONTENT_TYPE_ZIP": 1, + } +) + +func (x ContentType) Enum() *ContentType { + p := new(ContentType) + *p = x + return p +} + +func (x ContentType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ContentType) Descriptor() protoreflect.EnumDescriptor { + return file_cc_arduino_cli_files_v1_files_proto_enumTypes[0].Descriptor() +} + +func (ContentType) Type() protoreflect.EnumType { + return &file_cc_arduino_cli_files_v1_files_proto_enumTypes[0] +} + +func (x ContentType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ContentType.Descriptor instead. +func (ContentType) EnumDescriptor() ([]byte, []int) { + return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{0} +} + +type LoadFileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // path as it's returned in LoadSketchResponse for instance + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + // Optional + Type ContentType `protobuf:"varint,2,opt,name=type,proto3,enum=cc.arduino.cli.files.v1.ContentType" json:"type,omitempty"` +} + +func (x *LoadFileRequest) Reset() { + *x = LoadFileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoadFileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoadFileRequest) ProtoMessage() {} + +func (x *LoadFileRequest) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoadFileRequest.ProtoReflect.Descriptor instead. +func (*LoadFileRequest) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{0} +} + +func (x *LoadFileRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *LoadFileRequest) GetType() ContentType { + if x != nil { + return x.Type + } + return ContentType_CONTENT_TYPE_RAW_UNSPECIFIED +} + +type LoadFileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // File content + Content []byte `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"` + // is skipped in case of error + Type ContentType `protobuf:"varint,2,opt,name=type,proto3,enum=cc.arduino.cli.files.v1.ContentType" json:"type,omitempty"` +} + +func (x *LoadFileResponse) Reset() { + *x = LoadFileResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoadFileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoadFileResponse) ProtoMessage() {} + +func (x *LoadFileResponse) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoadFileResponse.ProtoReflect.Descriptor instead. +func (*LoadFileResponse) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{1} +} + +func (x *LoadFileResponse) GetContent() []byte { + if x != nil { + return x.Content + } + return nil +} + +func (x *LoadFileResponse) GetType() ContentType { + if x != nil { + return x.Type + } + return ContentType_CONTENT_TYPE_RAW_UNSPECIFIED +} + +var File_cc_arduino_cli_files_v1_files_proto protoreflect.FileDescriptor + +var file_cc_arduino_cli_files_v1_files_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, + 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x5f, + 0x0a, 0x0f, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, + 0x66, 0x0a, 0x10, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x38, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x63, + 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x2a, 0x45, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x4e, + 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x41, 0x57, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x4e, 0x54, + 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x5a, 0x49, 0x50, 0x10, 0x01, 0x32, 0x71, + 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x61, + 0x0a, 0x08, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x28, 0x2e, 0x63, 0x63, 0x2e, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, + 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, + 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, + 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cc_arduino_cli_files_v1_files_proto_rawDescOnce sync.Once + file_cc_arduino_cli_files_v1_files_proto_rawDescData = file_cc_arduino_cli_files_v1_files_proto_rawDesc +) + +func file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP() []byte { + file_cc_arduino_cli_files_v1_files_proto_rawDescOnce.Do(func() { + file_cc_arduino_cli_files_v1_files_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_cli_files_v1_files_proto_rawDescData) + }) + return file_cc_arduino_cli_files_v1_files_proto_rawDescData +} + +var file_cc_arduino_cli_files_v1_files_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_cc_arduino_cli_files_v1_files_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cc_arduino_cli_files_v1_files_proto_goTypes = []interface{}{ + (ContentType)(0), // 0: cc.arduino.cli.files.v1.ContentType + (*LoadFileRequest)(nil), // 1: cc.arduino.cli.files.v1.LoadFileRequest + (*LoadFileResponse)(nil), // 2: cc.arduino.cli.files.v1.LoadFileResponse +} +var file_cc_arduino_cli_files_v1_files_proto_depIdxs = []int32{ + 0, // 0: cc.arduino.cli.files.v1.LoadFileRequest.type:type_name -> cc.arduino.cli.files.v1.ContentType + 0, // 1: cc.arduino.cli.files.v1.LoadFileResponse.type:type_name -> cc.arduino.cli.files.v1.ContentType + 1, // 2: cc.arduino.cli.files.v1.FilesService.LoadFile:input_type -> cc.arduino.cli.files.v1.LoadFileRequest + 2, // 3: cc.arduino.cli.files.v1.FilesService.LoadFile:output_type -> cc.arduino.cli.files.v1.LoadFileResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_cc_arduino_cli_files_v1_files_proto_init() } +func file_cc_arduino_cli_files_v1_files_proto_init() { + if File_cc_arduino_cli_files_v1_files_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cc_arduino_cli_files_v1_files_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoadFileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_cli_files_v1_files_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoadFileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cc_arduino_cli_files_v1_files_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_cc_arduino_cli_files_v1_files_proto_goTypes, + DependencyIndexes: file_cc_arduino_cli_files_v1_files_proto_depIdxs, + EnumInfos: file_cc_arduino_cli_files_v1_files_proto_enumTypes, + MessageInfos: file_cc_arduino_cli_files_v1_files_proto_msgTypes, + }.Build() + File_cc_arduino_cli_files_v1_files_proto = out.File + file_cc_arduino_cli_files_v1_files_proto_rawDesc = nil + file_cc_arduino_cli_files_v1_files_proto_goTypes = nil + file_cc_arduino_cli_files_v1_files_proto_depIdxs = nil +} diff --git a/rpc/cc/arduino/cli/files/v1/files.proto b/rpc/cc/arduino/cli/files/v1/files.proto new file mode 100644 index 00000000000..fa9d1180620 --- /dev/null +++ b/rpc/cc/arduino/cli/files/v1/files.proto @@ -0,0 +1,45 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.files.v1; + +option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1;files"; + +// Arduino Files service API +service FilesService { + // Load file content from the file system + rpc LoadFile(LoadFileRequest) returns (LoadFileResponse) {} +} + +enum ContentType { + CONTENT_TYPE_RAW_UNSPECIFIED = 0; + CONTENT_TYPE_ZIP = 1; +} + +message LoadFileRequest { + // path as it's returned in LoadSketchResponse for instance + string path = 1; + // Optional + ContentType type = 2; +} + +message LoadFileResponse { + // File content + bytes content = 1; + // is skipped in case of error + ContentType type = 2; +} diff --git a/rpc/cc/arduino/cli/files/v1/files_grpc.pb.go b/rpc/cc/arduino/cli/files/v1/files_grpc.pb.go new file mode 100644 index 00000000000..3d6fa97ec14 --- /dev/null +++ b/rpc/cc/arduino/cli/files/v1/files_grpc.pb.go @@ -0,0 +1,103 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package files + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// FilesServiceClient is the client API for FilesService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type FilesServiceClient interface { + // Load file content from the file system + LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) +} + +type filesServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewFilesServiceClient(cc grpc.ClientConnInterface) FilesServiceClient { + return &filesServiceClient{cc} +} + +func (c *filesServiceClient) LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) { + out := new(LoadFileResponse) + err := c.cc.Invoke(ctx, "/cc.arduino.cli.files.v1.FilesService/LoadFile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// FilesServiceServer is the server API for FilesService service. +// All implementations must embed UnimplementedFilesServiceServer +// for forward compatibility +type FilesServiceServer interface { + // Load file content from the file system + LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) + mustEmbedUnimplementedFilesServiceServer() +} + +// UnimplementedFilesServiceServer must be embedded to have forward compatible implementations. +type UnimplementedFilesServiceServer struct { +} + +func (UnimplementedFilesServiceServer) LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoadFile not implemented") +} +func (UnimplementedFilesServiceServer) mustEmbedUnimplementedFilesServiceServer() {} + +// UnsafeFilesServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to FilesServiceServer will +// result in compilation errors. +type UnsafeFilesServiceServer interface { + mustEmbedUnimplementedFilesServiceServer() +} + +func RegisterFilesServiceServer(s grpc.ServiceRegistrar, srv FilesServiceServer) { + s.RegisterService(&FilesService_ServiceDesc, srv) +} + +func _FilesService_LoadFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoadFileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FilesServiceServer).LoadFile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cc.arduino.cli.files.v1.FilesService/LoadFile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FilesServiceServer).LoadFile(ctx, req.(*LoadFileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// FilesService_ServiceDesc is the grpc.ServiceDesc for FilesService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var FilesService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cc.arduino.cli.files.v1.FilesService", + HandlerType: (*FilesServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LoadFile", + Handler: _FilesService_LoadFile_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cc/arduino/cli/files/v1/files.proto", +}