//go:build darwin

package usbip

import (
	"fmt"
	"io"

	"github.com/duffy/usb-server/internal/usb"
)

// Sharing needs a way to submit URBs to a physical device, which macOS only
// offers through IOKit. Until that backend exists the server is a stub, so
// that the rest of the client still builds and runs here.

type Server struct{}

func NewServer(dev *usb.Device) *Server { return &Server{} }

func (s *Server) Attach() error {
	return fmt.Errorf("sharing USB devices is not implemented on macOS (needs an IOKit backend)")
}

func (s *Server) Detach() {}

func (s *Server) BuildDeviceDescriptor() DeviceDescriptor { return DeviceDescriptor{} }

func (s *Server) BuildInterfaceDescriptors() []InterfaceDescriptor { return nil }

func (s *Server) HandleConnection(r io.Reader, w io.Writer) error {
	return fmt.Errorf("sharing USB devices is not implemented on macOS")
}

func (s *Server) HandleDevlistRequest() ([]byte, error) {
	return nil, fmt.Errorf("sharing USB devices is not implemented on macOS")
}

func (s *Server) HandleImportRequest(requestedBusID string) ([]byte, error) {
	return nil, fmt.Errorf("sharing USB devices is not implemented on macOS")
}

func (s *Server) ReadManagementRequest(r io.Reader) ([]byte, bool, error) {
	return nil, false, fmt.Errorf("sharing USB devices is not implemented on macOS")
}
