Crate book_lib

Crate book_lib 

Source
Expand description

§book_lib

A main module for the book managing library. The main goal of the library is to see the PDF files from all the filesystem on your PC in one place. The library provides an API for creating/updating/deleting a “book” that represents a PDF by it’s path and name.

The library uses sqlite as a database manager and stores the data in the $HOME/.config/book-cli/books.db

§Usage

  1. Create a connection to the database:
use book_lib::{db, book};

let connection = book_lib::db::setup();
  1. Create a new book
let new_book = book::Book::init("book_name".to_string(), "path_to/your/file.pdf".to_string(), None, false);
book_lib::create_book(&connection, &new_book); //creating new book in the DB
  1. Make it favourite
book_lib::update_favourite(&connection, &("book_name".to_string()), true); //true to be favourite, false not to be
  1. Remove the book
book_lib::remove_book(&connection, &("book_name".to_string()));

§Examples of implementation

§Examples of implementation

  1. cli for managing PDFs
  2. GUI for managing PDFs

Modules§

book
A module that contains a Book implementation and associated methods and functions.
db
A module provides the most essential function for managing books in the database
errors
help
Module for simple helping function

Functions§

create_book
Creates a book by the given book data.
get_book
Returns a book by given name or an error.
get_books
Returns all the books stored in the database or an error.
remove_book
Removes a book by the given name or an error.
update_favourite
Update the books favourite state by the book’s name.