// 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 SignatureGattWriteRequestedEventArgs string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattWriteRequestedEventArgs;{2dec8bbe-a73a-471a-94d5-037deadd0806})"

type GattWriteRequestedEventArgs struct {
	ole.IUnknown
}

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

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

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

const GUIDiGattWriteRequestedEventArgs string = "2dec8bbe-a73a-471a-94d5-037deadd0806"
const SignatureiGattWriteRequestedEventArgs string = "{2dec8bbe-a73a-471a-94d5-037deadd0806}"

type iGattWriteRequestedEventArgs struct {
	ole.IInspectable
}

type iGattWriteRequestedEventArgsVtbl struct {
	ole.IInspectableVtbl

	GetSession      uintptr
	GetDeferral     uintptr
	GetRequestAsync uintptr
}

func (v *iGattWriteRequestedEventArgs) VTable() *iGattWriteRequestedEventArgsVtbl {
	return (*iGattWriteRequestedEventArgsVtbl)(unsafe.Pointer(v.RawVTable))
}

func (v *iGattWriteRequestedEventArgs) 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 *iGattWriteRequestedEventArgs) 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 *iGattWriteRequestedEventArgs) 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
}
