// Code generated by winrt-go-gen. DO NOT EDIT.

//go:build windows

//nolint:all
package streams

import (
	"syscall"
	"unsafe"

	"github.com/go-ole/go-ole"
)

const GUIDIBuffer string = "905a0fe0-bc53-11df-8c49-001e4fc686da"
const SignatureIBuffer string = "{905a0fe0-bc53-11df-8c49-001e4fc686da}"

type IBuffer struct {
	ole.IInspectable
}

type IBufferVtbl struct {
	ole.IInspectableVtbl

	GetCapacity uintptr
	GetLength   uintptr
	SetLength   uintptr
}

func (v *IBuffer) VTable() *IBufferVtbl {
	return (*IBufferVtbl)(unsafe.Pointer(v.RawVTable))
}

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

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

	return out, nil
}

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

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

	return out, nil
}

func (v *IBuffer) SetLength(value uint32) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().SetLength,
		uintptr(unsafe.Pointer(v)), // this
		uintptr(value),             // in uint32
	)

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

	return nil
}
