common

package
v0.0.0-...-71e9170 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrISBN      = fmt.Errorf("missing ISBN")
	ErrDuplicate = fmt.Errorf("duplicate book")
	ErrMissing   = fmt.Errorf("missing book")
)

List of errors

Functions

This section is empty.

Types

type Book

type Book struct {
	ISBN          string
	Title, Author string
	Year, Pages   int
}

Book represents a book entry

func (Book) String

func (b Book) String() string

type Progress

type Progress struct {
	ISBN  string
	Pages int
}

type ReadingList

type ReadingList struct {
	Books    []Book
	Progress []int
}

ReadingList keeps tracks of books and pages read

func (*ReadingList) AddBook

func (r *ReadingList) AddBook(b Book) error

AddBook checks if the book is not present and adds it

func (*ReadingList) AdvanceProgress

func (r *ReadingList) AdvanceProgress(isbn string, pages int) error

AdvanceProgress adds the pages the progress of a book

func (*ReadingList) GetProgress

func (r *ReadingList) GetProgress(isbn string) (int, error)

GetProgress returns the progress of abbok

func (*ReadingList) RemoveBook

func (r *ReadingList) RemoveBook(isbn string) error

RemoveBook removes the book from list and forgets its progress

func (*ReadingList) SetProgress

func (r *ReadingList) SetProgress(isbn string, pages int) error

SetProgress changes the progress of a book

type ReadingService

type ReadingService struct {
	ReadingList
}

ReadingService adapts ReadingList for RPC

func (*ReadingService) AddBook

func (r *ReadingService) AddBook(b Book, success *bool) error

func (*ReadingService) AdvanceProgress

func (r *ReadingService) AdvanceProgress(p Progress, success *bool) error

func (*ReadingService) GetProgress

func (r *ReadingService) GetProgress(isbn string, pages *int) (err error)

func (*ReadingService) RemoveBook

func (r *ReadingService) RemoveBook(isbn string, success *bool) error

func (*ReadingService) SetProgress

func (r *ReadingService) SetProgress(p Progress, success *bool) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL