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

const SignatureGattReadResult string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadResult;{63a66f08-1aea-4c4c-a50f-97bae474b348})"

type GattReadResult struct {
	ole.IUnknown
}

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

func (impl *GattReadResult) GetValue() (*streams.IBuffer, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadResult))
	defer itf.Release()
	v := (*iGattReadResult)(unsafe.Pointer(itf))
	return v.GetValue()
}

const GUIDiGattReadResult string = "63a66f08-1aea-4c4c-a50f-97bae474b348"
const SignatureiGattReadResult string = "{63a66f08-1aea-4c4c-a50f-97bae474b348}"

type iGattReadResult struct {
	ole.IInspectable
}

type iGattReadResultVtbl struct {
	ole.IInspectableVtbl

	GetStatus uintptr
	GetValue  uintptr
}

func (v *iGattReadResult) VTable() *iGattReadResultVtbl {
	return (*iGattReadResultVtbl)(unsafe.Pointer(v.RawVTable))
}

func (v *iGattReadResult) 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 *iGattReadResult) GetValue() (*streams.IBuffer, error) {
	var out *streams.IBuffer
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetValue,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out streams.IBuffer
	)

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

	return out, nil
}

const GUIDiGattReadResult2 string = "a10f50a0-fb43-48af-baaa-638a5c6329fe"
const SignatureiGattReadResult2 string = "{a10f50a0-fb43-48af-baaa-638a5c6329fe}"

type iGattReadResult2 struct {
	ole.IInspectable
}

type iGattReadResult2Vtbl struct {
	ole.IInspectableVtbl

	GetProtocolError uintptr
}

func (v *iGattReadResult2) VTable() *iGattReadResult2Vtbl {
	return (*iGattReadResult2Vtbl)(unsafe.Pointer(v.RawVTable))
}
