package host

import (
	"context"
	"encoding/json"
)

func (c Core) FindDevices(ctx context.Context, in *FindDevicesInput) (*FindDeviceOutput, error) {
	marshal, err := json.Marshal(in)
	if err != nil {
		return nil, err
	}
	result, err := c.Plugin.CallHost("findDevices", marshal)

	if err != nil {
		return nil, err
	}

	out := FindDeviceOutput{}
	if err = json.Unmarshal(result, &out); err != nil {
		return nil, err
	}
	return &out, nil
}
