volume_id.go 351 B

123456789101112131415161718
  1. package needle
  2. import (
  3. "strconv"
  4. )
  5. type VolumeId uint32
  6. func NewVolumeId(vid string) (VolumeId, error) {
  7. volumeId, err := strconv.ParseUint(vid, 10, 64)
  8. return VolumeId(volumeId), err
  9. }
  10. func (vid VolumeId) String() string {
  11. return strconv.FormatUint(uint64(vid), 10)
  12. }
  13. func (vid VolumeId) Next() VolumeId {
  14. return VolumeId(uint32(vid) + 1)
  15. }