func IDFromHash(prefix IDPrefix, hash []byte) (ID, error) {
	var id ID

	if len(hash) > len(id.data) {
		return EmptyID, errors.Errorf("hash too long")
	}

	if len(hash) == 0 {
		return EmptyID, errors.Errorf("hash too short")
	}

	if err := prefix.ValidateSingle(); err != nil {
		return EmptyID, errors.Wrap(err, "invalid prefix")
	}

	if len(prefix) > 0 {
		id.prefix = prefix[0]
	}

	id.idLen = byte(len(hash))
	copy(id.data[:], hash)

	return id, nil
}
// IDFromHash constructs content ID from a prefix and a hash.
IDFromHash constructs content ID from a prefix and a hash.
// IDFromHash constructs content ID from a prefix and a hash .
func IDFromHash(prefix IDPrefix, hash []byte) (ID, error) {
	var id ID
	if len(hash) > len(id.data) {
		return EmptyID, errors.Errorf("hash too long")
	}
	if len(hash) == 0 {
		return EmptyID, errors.Errorf("hash too short")
	}
	if err := prefix.ValidateSingle(); err != nil {
		return EmptyID, errors.Wrap(err, "invalid prefix")
	}
	if len(prefix) > 0 {
		id.prefix = prefix[0]
	}
	id.idLen = byte(len(hash))
	copy(id.data[:], hash)
	return id, nil
}
func IDFromHash ( prefix IDPrefix , hash [ ] byte ) ( ID , error ) { var id ID if len ( hash ) > len ( id . data ) { return EmptyID , errors . Errorf ( " " ) } if len ( hash ) == 0 { return EmptyID , errors . Errorf ( " " ) } if err := prefix . ValidateSingle ( ) ; err != nil { return EmptyID , errors . Wrap ( err , " " ) } if len ( prefix ) > 0 { id . prefix = prefix [ 0 ] } id . idLen = byte ( len ( hash ) ) copy ( id . data [ : ] , hash ) return id , nil }
IDFromHash constructs content ID from a prefix and a hash.
IDFromHash constructs content ID from a prefix and a hash .