// Copyright 2025 Michael Li <alimy@niubiu.com>. All rights reserved.
// Use of this source code is governed by Apache License 2.0 that
// can be found in the LICENSE file.

package assert

// anyTypeAssertor a common type assert for type T
type anyTypeAssertor[T any] struct{}

// anyTypeAssertor2 a common type assert for type B(Binding) and R(Render)
type anyTypeAssertor2[B, R any] struct{}

// anyTypeAssertor3 a common type assert for type B(Binding)/P(Params) and R(Render)
type anyTypeAssertor3[B, P, R any] struct{}

// anyTypeAssertor4 a common type assert for type C and T
type anyTypeAssertor4[C, T any] struct{}

func (anyTypeAssertor[T]) AssertBinding(obj any) bool {
	_, ok := obj.(Binding[T])
	return ok
}

func (anyTypeAssertor[T]) AssertRender(obj any) bool {
	_, ok := obj.(Render[T])
	return ok
}

func (anyTypeAssertor2[B, R]) AssertBinding(obj any) bool {
	_, ok := obj.(Binding[B])
	return ok
}

func (anyTypeAssertor2[B, R]) AssertRender(obj any) bool {
	_, ok := obj.(Render[R])
	return ok
}

func (anyTypeAssertor3[B, P, R]) AssertBinding(obj any) bool {
	_, ok := obj.(Binding2[B, P])
	return ok
}

func (anyTypeAssertor3[B, P, R]) AssertRender(obj any) bool {
	_, ok := obj.(Render[R])
	return ok
}

func (anyTypeAssertor4[C, T]) AssertBinding(obj any) bool {
	_, ok := obj.(Binding2[C, T])
	return ok
}

func (anyTypeAssertor4[C, T]) AssertRender(obj any) bool {
	_, ok := obj.(Render2[C, T])
	return ok
}
