// 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"
	"git.savin.nyc/alex/go-winrt/windows/foundation/collections"
	"git.savin.nyc/alex/go-winrt/windows/storage/streams"
	"github.com/go-ole/go-ole"
)

const SignatureGattLocalCharacteristic string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristic;{aede376d-5412-4d74-92a8-8deb8526829c})"

type GattLocalCharacteristic struct {
	ole.IUnknown
}

func (impl *GattLocalCharacteristic) GetUuid() (syscall.GUID, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetUuid()
}

func (impl *GattLocalCharacteristic) GetStaticValue() (*streams.IBuffer, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetStaticValue()
}

func (impl *GattLocalCharacteristic) GetCharacteristicProperties() (GattCharacteristicProperties, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetCharacteristicProperties()
}

func (impl *GattLocalCharacteristic) GetReadProtectionLevel() (GattProtectionLevel, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetReadProtectionLevel()
}

func (impl *GattLocalCharacteristic) GetWriteProtectionLevel() (GattProtectionLevel, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetWriteProtectionLevel()
}

func (impl *GattLocalCharacteristic) CreateDescriptorAsync(descriptorUuid syscall.GUID, parameters *GattLocalDescriptorParameters) (*foundation.IAsyncOperation, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.CreateDescriptorAsync(descriptorUuid, parameters)
}

func (impl *GattLocalCharacteristic) GetDescriptors() (*collections.IVectorView, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetDescriptors()
}

func (impl *GattLocalCharacteristic) GetUserDescription() (string, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetUserDescription()
}

func (impl *GattLocalCharacteristic) GetPresentationFormats() (*collections.IVectorView, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetPresentationFormats()
}

func (impl *GattLocalCharacteristic) GetSubscribedClients() (*collections.IVectorView, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.GetSubscribedClients()
}

func (impl *GattLocalCharacteristic) AddSubscribedClientsChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.AddSubscribedClientsChanged(handler)
}

func (impl *GattLocalCharacteristic) RemoveSubscribedClientsChanged(token foundation.EventRegistrationToken) error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.RemoveSubscribedClientsChanged(token)
}

func (impl *GattLocalCharacteristic) AddReadRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.AddReadRequested(handler)
}

func (impl *GattLocalCharacteristic) RemoveReadRequested(token foundation.EventRegistrationToken) error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.RemoveReadRequested(token)
}

func (impl *GattLocalCharacteristic) AddWriteRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.AddWriteRequested(handler)
}

func (impl *GattLocalCharacteristic) RemoveWriteRequested(token foundation.EventRegistrationToken) error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.RemoveWriteRequested(token)
}

func (impl *GattLocalCharacteristic) NotifyValueAsync(value *streams.IBuffer) (*foundation.IAsyncOperation, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.NotifyValueAsync(value)
}

func (impl *GattLocalCharacteristic) NotifyValueForSubscribedClientAsync(value *streams.IBuffer, subscribedClient *GattSubscribedClient) (*foundation.IAsyncOperation, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic))
	defer itf.Release()
	v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf))
	return v.NotifyValueForSubscribedClientAsync(value, subscribedClient)
}

const GUIDiGattLocalCharacteristic string = "aede376d-5412-4d74-92a8-8deb8526829c"
const SignatureiGattLocalCharacteristic string = "{aede376d-5412-4d74-92a8-8deb8526829c}"

type iGattLocalCharacteristic struct {
	ole.IInspectable
}

type iGattLocalCharacteristicVtbl struct {
	ole.IInspectableVtbl

	GetUuid                             uintptr
	GetStaticValue                      uintptr
	GetCharacteristicProperties         uintptr
	GetReadProtectionLevel              uintptr
	GetWriteProtectionLevel             uintptr
	CreateDescriptorAsync               uintptr
	GetDescriptors                      uintptr
	GetUserDescription                  uintptr
	GetPresentationFormats              uintptr
	GetSubscribedClients                uintptr
	AddSubscribedClientsChanged         uintptr
	RemoveSubscribedClientsChanged      uintptr
	AddReadRequested                    uintptr
	RemoveReadRequested                 uintptr
	AddWriteRequested                   uintptr
	RemoveWriteRequested                uintptr
	NotifyValueAsync                    uintptr
	NotifyValueForSubscribedClientAsync uintptr
}

func (v *iGattLocalCharacteristic) VTable() *iGattLocalCharacteristicVtbl {
	return (*iGattLocalCharacteristicVtbl)(unsafe.Pointer(v.RawVTable))
}

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

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

	return out, nil
}

func (v *iGattLocalCharacteristic) GetStaticValue() (*streams.IBuffer, error) {
	var out *streams.IBuffer
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetStaticValue,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out streams.IBuffer
	)

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

	return out, nil
}

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

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

	return out, nil
}

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

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

	return out, nil
}

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

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

	return out, nil
}

func (v *iGattLocalCharacteristic) CreateDescriptorAsync(descriptorUuid syscall.GUID, parameters *GattLocalDescriptorParameters) (*foundation.IAsyncOperation, error) {
	var out *foundation.IAsyncOperation
	hr, _, _ := syscall.SyscallN(
		v.VTable().CreateDescriptorAsync,
		uintptr(unsafe.Pointer(v)),               // this
		uintptr(unsafe.Pointer(&descriptorUuid)), // in syscall.GUID
		uintptr(unsafe.Pointer(parameters)),      // in GattLocalDescriptorParameters
		uintptr(unsafe.Pointer(&out)),            // out foundation.IAsyncOperation
	)

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

	return out, nil
}

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

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

	return out, nil
}

func (v *iGattLocalCharacteristic) GetUserDescription() (string, error) {
	var outHStr ole.HString
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetUserDescription,
		uintptr(unsafe.Pointer(v)),        // this
		uintptr(unsafe.Pointer(&outHStr)), // out string
	)

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

	out := outHStr.String()
	ole.DeleteHString(outHStr)
	return out, nil
}

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

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

	return out, nil
}

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

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

	return out, nil
}

func (v *iGattLocalCharacteristic) AddSubscribedClientsChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) {
	var out foundation.EventRegistrationToken
	hr, _, _ := syscall.SyscallN(
		v.VTable().AddSubscribedClientsChanged,
		uintptr(unsafe.Pointer(v)),       // this
		uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler
		uintptr(unsafe.Pointer(&out)),    // out foundation.EventRegistrationToken
	)

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

	return out, nil
}

func (v *iGattLocalCharacteristic) RemoveSubscribedClientsChanged(token foundation.EventRegistrationToken) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().RemoveSubscribedClientsChanged,
		uintptr(unsafe.Pointer(v)),      // this
		uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken
	)

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

	return nil
}

func (v *iGattLocalCharacteristic) AddReadRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) {
	var out foundation.EventRegistrationToken
	hr, _, _ := syscall.SyscallN(
		v.VTable().AddReadRequested,
		uintptr(unsafe.Pointer(v)),       // this
		uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler
		uintptr(unsafe.Pointer(&out)),    // out foundation.EventRegistrationToken
	)

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

	return out, nil
}

func (v *iGattLocalCharacteristic) RemoveReadRequested(token foundation.EventRegistrationToken) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().RemoveReadRequested,
		uintptr(unsafe.Pointer(v)),      // this
		uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken
	)

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

	return nil
}

func (v *iGattLocalCharacteristic) AddWriteRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) {
	var out foundation.EventRegistrationToken
	hr, _, _ := syscall.SyscallN(
		v.VTable().AddWriteRequested,
		uintptr(unsafe.Pointer(v)),       // this
		uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler
		uintptr(unsafe.Pointer(&out)),    // out foundation.EventRegistrationToken
	)

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

	return out, nil
}

func (v *iGattLocalCharacteristic) RemoveWriteRequested(token foundation.EventRegistrationToken) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().RemoveWriteRequested,
		uintptr(unsafe.Pointer(v)),      // this
		uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken
	)

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

	return nil
}

func (v *iGattLocalCharacteristic) NotifyValueAsync(value *streams.IBuffer) (*foundation.IAsyncOperation, error) {
	var out *foundation.IAsyncOperation
	hr, _, _ := syscall.SyscallN(
		v.VTable().NotifyValueAsync,
		uintptr(unsafe.Pointer(v)),     // this
		uintptr(unsafe.Pointer(value)), // in streams.IBuffer
		uintptr(unsafe.Pointer(&out)),  // out foundation.IAsyncOperation
	)

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

	return out, nil
}

func (v *iGattLocalCharacteristic) NotifyValueForSubscribedClientAsync(value *streams.IBuffer, subscribedClient *GattSubscribedClient) (*foundation.IAsyncOperation, error) {
	var out *foundation.IAsyncOperation
	hr, _, _ := syscall.SyscallN(
		v.VTable().NotifyValueForSubscribedClientAsync,
		uintptr(unsafe.Pointer(v)),                // this
		uintptr(unsafe.Pointer(value)),            // in streams.IBuffer
		uintptr(unsafe.Pointer(subscribedClient)), // in GattSubscribedClient
		uintptr(unsafe.Pointer(&out)),             // out foundation.IAsyncOperation
	)

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

	return out, nil
}
