package pgtype

import (
	
	
	
)

type Macaddr struct {
	Addr   net.HardwareAddr
	Status Status
}

func ( *Macaddr) ( interface{}) error {
	if  == nil {
		* = Macaddr{Status: Null}
		return nil
	}

	if ,  := .(interface{ () interface{} });  {
		 := .()
		if  !=  {
			return .()
		}
	}

	switch value := .(type) {
	case net.HardwareAddr:
		 := make(net.HardwareAddr, len())
		copy(, )
		* = Macaddr{Addr: , Status: Present}
	case string:
		,  := net.ParseMAC()
		if  != nil {
			return 
		}
		* = Macaddr{Addr: , Status: Present}
	case *net.HardwareAddr:
		if  == nil {
			* = Macaddr{Status: Null}
		} else {
			return .(*)
		}
	case *string:
		if  == nil {
			* = Macaddr{Status: Null}
		} else {
			return .(*)
		}
	default:
		if ,  := underlyingPtrType();  {
			return .()
		}
		return fmt.Errorf("cannot convert %v to Macaddr", )
	}

	return nil
}

func ( Macaddr) () interface{} {
	switch .Status {
	case Present:
		return .Addr
	case Null:
		return nil
	default:
		return .Status
	}
}

func ( *Macaddr) ( interface{}) error {
	switch .Status {
	case Present:
		switch v := .(type) {
		case *net.HardwareAddr:
			* = make(net.HardwareAddr, len(.Addr))
			copy(*, .Addr)
			return nil
		case *string:
			* = .Addr.String()
			return nil
		default:
			if ,  := GetAssignToDstType();  {
				return .()
			}
			return fmt.Errorf("unable to assign to %T", )
		}
	case Null:
		return NullAssignTo()
	}

	return fmt.Errorf("cannot decode %#v into %T", , )
}

func ( *Macaddr) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = Macaddr{Status: Null}
		return nil
	}

	,  := net.ParseMAC(string())
	if  != nil {
		return 
	}

	* = Macaddr{Addr: , Status: Present}
	return nil
}

func ( *Macaddr) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = Macaddr{Status: Null}
		return nil
	}

	if len() != 6 {
		return fmt.Errorf("Received an invalid size for a macaddr: %d", len())
	}

	 := make(net.HardwareAddr, 6)
	copy(, )

	* = Macaddr{Addr: , Status: Present}

	return nil
}

func ( Macaddr) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	return append(, .Addr.String()...), nil
}
EncodeBinary encodes src into w.
func ( Macaddr) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	return append(, .Addr...), nil
}
Scan implements the database/sql Scanner interface.
func ( *Macaddr) ( interface{}) error {
	if  == nil {
		* = Macaddr{Status: Null}
		return nil
	}

	switch src := .(type) {
	case string:
		return .DecodeText(nil, []byte())
	case []byte:
		 := make([]byte, len())
		copy(, )
		return .DecodeText(nil, )
	}

	return fmt.Errorf("cannot scan %T", )
}
Value implements the database/sql/driver Valuer interface.
func ( Macaddr) () (driver.Value, error) {
	return EncodeValueText()