// Restore restores the pool to the previously captured state. ErrMismatchedNetwork // is returned if the provided port range doesn't exactly match the previous range. func (r *Allocator) Restore(into *mcs.Range, data []byte) error { if into.String() != r.r.String() { return ErrMismatchedRange } snapshottable, ok := r.alloc.(allocator.Snapshottable) if !ok { return fmt.Errorf("not a snapshottable allocator") } return snapshottable.Restore(into.String(), data) }
// New creates a Allocator over a UID range, calling factory to construct the backing store. func New(r *mcs.Range, factory allocator.AllocatorFactory) *Allocator { return &Allocator{ r: r, alloc: factory(int(r.Size()), r.String()), } }