Skip to content

Commit 6f509d6

Browse files
committed
Add function to convert discovery.Port to rpc.Port
1 parent c548aa1 commit 6f509d6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arduino/discovery/discovery.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/arduino/arduino-cli/cli/globals"
2525
"github.com/arduino/arduino-cli/executils"
26+
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2627
"github.com/arduino/go-properties-orderedmap"
2728
"github.com/pkg/errors"
2829
)
@@ -62,6 +63,17 @@ type Port struct {
6263
Properties *properties.Map `json:"properties"`
6364
}
6465

66+
// ToRPC converts Port into rpc.Port
67+
func (p *Port) ToRPC() *rpc.Port {
68+
return &rpc.Port{
69+
Address: p.Address,
70+
Label: p.AddressLabel,
71+
Protocol: p.Protocol,
72+
ProtocolLabel: p.ProtocolLabel,
73+
Properties: p.Properties.AsMap(),
74+
}
75+
}
76+
6577
func (p *Port) String() string {
6678
if p == nil {
6779
return "none"

0 commit comments

Comments
 (0)