// Code generated by winrt-go-gen. DO NOT EDIT.

//go:build windows

//nolint:all
package genericattributeprofile

import (
	"syscall"
	"unsafe"

	"git.savin.nyc/alex/go-winrt/windows/devices/bluetooth"
	"github.com/go-ole/go-ole"
)

const SignatureGattServiceProviderResult string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderResult;{764696d8-c53e-428c-8a48-67afe02c3ae6})"

type GattServiceProviderResult struct {
	ole.IUnknown
}

func (impl *GattServiceProviderResult) GetError() (bluetooth.BluetoothError, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderResult))
	defer itf.Release()
	v := (*iGattServiceProviderResult)(unsafe.Pointer(itf))
	return v.GetError()
}

func (impl *GattServiceProviderResult) GetServiceProvider() (*GattServiceProvider, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderResult))
	defer itf.Release()
	v := (*iGattServiceProviderResult)(unsafe.Pointer(itf))
	return v.GetServiceProvider()
}

const GUIDiGattServiceProviderResult string = "764696d8-c53e-428c-8a48-67afe02c3ae6"
const SignatureiGattServiceProviderResult string = "{764696d8-c53e-428c-8a48-67afe02c3ae6}"

type iGattServiceProviderResult struct {
	ole.IInspectable
}

type iGattServiceProviderResultVtbl struct {
	ole.IInspectableVtbl

	GetError           uintptr
	GetServiceProvider uintptr
}

func (v *iGattServiceProviderResult) VTable() *iGattServiceProviderResultVtbl {
	return (*iGattServiceProviderResultVtbl)(unsafe.Pointer(v.RawVTable))
}

func (v *iGattServiceProviderResult) GetError() (bluetooth.BluetoothError, error) {
	var out bluetooth.BluetoothError
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetError,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out bluetooth.BluetoothError
	)

	if hr != 0 {
		return bluetooth.BluetoothErrorSuccess, ole.NewError(hr)
	}

	return out, nil
}

func (v *iGattServiceProviderResult) GetServiceProvider() (*GattServiceProvider, error) {
	var out *GattServiceProvider
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetServiceProvider,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out GattServiceProvider
	)

	if hr != 0 {
		return nil, ole.NewError(hr)
	}

	return out, nil
}
