// Code generated by fastssz. DO NOT EDIT.
// Hash: c953c4b72fdc3f250f4227b181e286fe53fd663c5aa4f5cc3de6cc9998c7fdb7
// Version: 0.1.2
package signing

import (
	ssz "github.com/ferranbt/fastssz"
)

// MarshalSSZ ssz marshals the Container object
func (c *Container) MarshalSSZ() ([]byte, error) {
	return ssz.MarshalSSZ(c)
}

// MarshalSSZTo ssz marshals the Container object to a target array
func (c *Container) MarshalSSZTo(buf []byte) (dst []byte, err error) {
	dst = buf

	// Field (0) 'Root'
	if size := len(c.Root); size != 32 {
		err = ssz.ErrBytesLengthFn("Container.Root", size, 32)
		return
	}
	dst = append(dst, c.Root...)

	// Field (1) 'Domain'
	if size := len(c.Domain); size != 32 {
		err = ssz.ErrBytesLengthFn("Container.Domain", size, 32)
		return
	}
	dst = append(dst, c.Domain...)

	return
}

// UnmarshalSSZ ssz unmarshals the Container object
func (c *Container) UnmarshalSSZ(buf []byte) error {
	var err error
	size := uint64(len(buf))
	if size != 64 {
		return ssz.ErrSize
	}

	// Field (0) 'Root'
	if cap(c.Root) == 0 {
		c.Root = make([]byte, 0, len(buf[0:32]))
	}
	c.Root = append(c.Root, buf[0:32]...)

	// Field (1) 'Domain'
	if cap(c.Domain) == 0 {
		c.Domain = make([]byte, 0, len(buf[32:64]))
	}
	c.Domain = append(c.Domain, buf[32:64]...)

	return err
}

// SizeSSZ returns the ssz encoded size in bytes for the Container object
func (c *Container) SizeSSZ() (size int) {
	size = 64
	return
}

// HashTreeRoot ssz hashes the Container object
func (c *Container) HashTreeRoot() ([32]byte, error) {
	return ssz.HashWithDefaultHasher(c)
}

// HashTreeRootWith ssz hashes the Container object with a hasher
func (c *Container) HashTreeRootWith(hh ssz.HashWalker) (err error) {
	indx := hh.Index()

	// Field (0) 'Root'
	if size := len(c.Root); size != 32 {
		err = ssz.ErrBytesLengthFn("Container.Root", size, 32)
		return
	}
	hh.PutBytes(c.Root)

	// Field (1) 'Domain'
	if size := len(c.Domain); size != 32 {
		err = ssz.ErrBytesLengthFn("Container.Domain", size, 32)
		return
	}
	hh.PutBytes(c.Domain)

	hh.Merkleize(indx)
	return
}

// GetTree ssz hashes the Container object
func (c *Container) GetTree() (*ssz.Node, error) {
	return ssz.ProofTree(c)
}
