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

const SignatureGattReadRequestedEventArgs string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadRequestedEventArgs;{93497243-f39c-484b-8ab6-996ba486cfa3})"

type GattReadRequestedEventArgs struct {
	ole.IUnknown
}

func (impl *GattReadRequestedEventArgs) GetSession() (*GattSession, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequestedEventArgs))
	defer itf.Release()
	v := (*iGattReadRequestedEventArgs)(unsafe.Pointer(itf))
	return v.GetSession()
}

func (impl *GattReadRequestedEventArgs) GetDeferral() (*foundation.Deferral, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequestedEventArgs))
	defer itf.Release()
	v := (*iGattReadRequestedEventArgs)(unsafe.Pointer(itf))
	return v.GetDeferral()
}

func (impl *GattReadRequestedEventArgs) GetRequestAsync() (*foundation.IAsyncOperation, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequestedEventArgs))
	defer itf.Release()
	v := (*iGattReadRequestedEventArgs)(unsafe.Pointer(itf))
	return v.GetRequestAsync()
}

const GUIDiGattReadRequestedEventArgs string = "93497243-f39c-484b-8ab6-996ba486cfa3"
const SignatureiGattReadRequestedEventArgs string = "{93497243-f39c-484b-8ab6-996ba486cfa3}"

type iGattReadRequestedEventArgs struct {
	ole.IInspectable
}

type iGattReadRequestedEventArgsVtbl struct {
	ole.IInspectableVtbl

	GetSession      uintptr
	GetDeferral     uintptr
	GetRequestAsync uintptr
}

func (v *iGattReadRequestedEventArgs) VTable() *iGattReadRequestedEventArgsVtbl {
	return (*iGattReadRequestedEventArgsVtbl)(unsafe.Pointer(v.RawVTable))
}

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

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

	return out, nil
}

func (v *iGattReadRequestedEventArgs) GetDeferral() (*foundation.Deferral, error) {
	var out *foundation.Deferral
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetDeferral,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out foundation.Deferral
	)

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

	return out, nil
}

func (v *iGattReadRequestedEventArgs) GetRequestAsync() (*foundation.IAsyncOperation, error) {
	var out *foundation.IAsyncOperation
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetRequestAsync,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation
	)

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

	return out, nil
}
