2020-09-21 10:07:12 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2022-03-17 08:17:45 +00:00
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
2021-11-10 07:08:33 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/container"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
2020-09-21 10:07:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Source is an interface that wraps
|
|
|
|
// basic container receiving method.
|
|
|
|
type Source interface {
|
2022-04-21 11:28:05 +00:00
|
|
|
// Get reads the container from the storage by its identifier.
|
|
|
|
// It returns the pointer to the requested container and any error encountered.
|
2020-09-21 10:07:12 +00:00
|
|
|
//
|
|
|
|
// Get must return exactly one non-nil value.
|
2022-04-21 11:28:05 +00:00
|
|
|
// Get must return an error of type apistatus.ContainerNotFound if the container is not in the storage.
|
2020-09-21 10:07:12 +00:00
|
|
|
//
|
|
|
|
// Implementations must not retain the container pointer and modify
|
|
|
|
// the container through it.
|
2022-05-31 17:00:41 +00:00
|
|
|
Get(cid.ID) (*container.Container, error)
|
2020-09-21 10:07:12 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// IsErrNotFound checks if the error returned by Source.Get corresponds
|
|
|
|
// to the missing container.
|
2022-03-17 08:17:45 +00:00
|
|
|
func IsErrNotFound(err error) bool {
|
|
|
|
return errors.As(err, new(apistatus.ContainerNotFound))
|
|
|
|
}
|
2020-11-24 12:49:02 +00:00
|
|
|
|
|
|
|
// ErrEACLNotFound is returned by eACL storage implementations when
|
2022-04-21 11:28:05 +00:00
|
|
|
// the requested eACL table is not in the storage.
|
2020-11-24 12:49:02 +00:00
|
|
|
var ErrEACLNotFound = errors.New("extended ACL table is not set for this container")
|