// 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/foundation/collections"
	"github.com/go-ole/go-ole"
)

const SignatureGattCharacteristicsResult string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristicsResult;{1194945c-b257-4f3e-9db7-f68bc9a9aef2})"

type GattCharacteristicsResult struct {
	ole.IUnknown
}

func (impl *GattCharacteristicsResult) GetStatus() (GattCommunicationStatus, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattCharacteristicsResult))
	defer itf.Release()
	v := (*iGattCharacteristicsResult)(unsafe.Pointer(itf))
	return v.GetStatus()
}

func (impl *GattCharacteristicsResult) GetCharacteristics() (*collections.IVectorView, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattCharacteristicsResult))
	defer itf.Release()
	v := (*iGattCharacteristicsResult)(unsafe.Pointer(itf))
	return v.GetCharacteristics()
}

const GUIDiGattCharacteristicsResult string = "1194945c-b257-4f3e-9db7-f68bc9a9aef2"
const SignatureiGattCharacteristicsResult string = "{1194945c-b257-4f3e-9db7-f68bc9a9aef2}"

type iGattCharacteristicsResult struct {
	ole.IInspectable
}

type iGattCharacteristicsResultVtbl struct {
	ole.IInspectableVtbl

	GetStatus          uintptr
	GetProtocolError   uintptr
	GetCharacteristics uintptr
}

func (v *iGattCharacteristicsResult) VTable() *iGattCharacteristicsResultVtbl {
	return (*iGattCharacteristicsResultVtbl)(unsafe.Pointer(v.RawVTable))
}

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

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

	return out, nil
}

func (v *iGattCharacteristicsResult) GetCharacteristics() (*collections.IVectorView, error) {
	var out *collections.IVectorView
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetCharacteristics,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out collections.IVectorView
	)

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

	return out, nil
}
