2014-08-19 11:14:14 +02:00
|
|
|
// Copyright 2014 by Sascha L. Teichmann
|
|
|
|
// Use of this source code is governed by the MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2014-08-19 12:07:57 +02:00
|
|
|
import (
|
2014-08-19 12:27:42 +02:00
|
|
|
"errors"
|
2014-08-19 12:23:33 +02:00
|
|
|
|
|
|
|
"bitbucket.org/s_l_teichmann/mtredisalize/common"
|
2014-08-19 12:07:57 +02:00
|
|
|
)
|
|
|
|
|
2014-08-21 14:46:34 +02:00
|
|
|
// Error returned if a Producer has run to its end.
|
|
|
|
var ErrNoMoreBlocks = errors.New("No more blocks.")
|
2014-08-19 11:14:14 +02:00
|
|
|
|
|
|
|
type (
|
2014-08-21 14:46:34 +02:00
|
|
|
// Block data from Minetest database.
|
2014-08-19 11:14:14 +02:00
|
|
|
Block struct {
|
|
|
|
Coord common.Coord
|
|
|
|
Data []byte
|
|
|
|
}
|
|
|
|
|
2014-08-21 14:46:34 +02:00
|
|
|
// BlockProducer is used to over a existing Minetest database
|
|
|
|
// and return its content block by block.
|
|
|
|
BlockProducer interface {
|
|
|
|
// error is ErrNoMoreBlocks if it run out of blocks.
|
2014-08-20 15:34:20 +02:00
|
|
|
Next(*Block) error
|
2014-08-21 14:46:34 +02:00
|
|
|
// Closes the open database connections.
|
2014-08-19 11:14:14 +02:00
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
|
2014-08-21 14:46:34 +02:00
|
|
|
// BlockConsumer is used to store blocks in a new Minetest database.
|
2014-08-19 11:14:14 +02:00
|
|
|
BlockConsumer interface {
|
2014-08-20 15:34:20 +02:00
|
|
|
Consume(*Block) error
|
2014-08-21 14:46:34 +02:00
|
|
|
// Closes the open database connections.
|
2014-08-19 11:14:14 +02:00
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
)
|