Add "is"-flag setting when creating bookmark
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
c58b0d323e
commit
75ab0c1408
4 changed files with 47 additions and 1 deletions
|
@ -28,6 +28,7 @@ libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore"
|
|||
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
|
||||
libimagentrylink = { version = "0.10.0", path = "../../../lib/entry/libimagentrylink" }
|
||||
libimagentryurl = { version = "0.10.0", path = "../../../lib/entry/libimagentryurl" }
|
||||
libimagentryutil = { version = "0.10.0", path = "../../../lib/entry/libimagentryutil" }
|
||||
|
||||
[dependencies.uuid]
|
||||
version = "0.7"
|
||||
|
|
37
lib/domain/libimagbookmark/src/bookmark.rs
Normal file
37
lib/domain/libimagbookmark/src/bookmark.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// imag - the personal information management suite for the commandline
|
||||
// Copyright (C) 2015-2019 Matthias Beyer <mail@beyermatthias.de> and contributors
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; version
|
||||
// 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
|
||||
use failure::Fallible as Result;
|
||||
|
||||
use libimagentryutil::isa::Is;
|
||||
use libimagentryutil::isa::IsKindHeaderPathProvider;
|
||||
use libimagstore::store::Entry;
|
||||
|
||||
provide_kindflag_path!(pub IsBookmark, "bookmark.is_bookmark");
|
||||
|
||||
pub trait Bookmark {
|
||||
fn is_bookmark(&self) -> Result<bool>;
|
||||
}
|
||||
|
||||
impl Bookmark for Entry {
|
||||
fn is_bookmark(&self) -> Result<bool> {
|
||||
self.is::<IsBookmark>()
|
||||
}
|
||||
}
|
||||
|
|
@ -43,11 +43,13 @@ extern crate regex;
|
|||
#[macro_use] extern crate failure;
|
||||
|
||||
#[macro_use] extern crate libimagstore;
|
||||
#[macro_use] extern crate libimagentryutil;
|
||||
extern crate libimagerror;
|
||||
extern crate libimagentrylink;
|
||||
extern crate libimagentryurl;
|
||||
|
||||
module_entry_path_mod!("bookmark");
|
||||
|
||||
pub mod bookmark;
|
||||
pub mod store;
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@ use libimagstore::storeid::StoreId;
|
|||
use libimagstore::store::FileLockEntry;
|
||||
use libimagstore::iter::Entries;
|
||||
use libimagentryurl::link::Link;
|
||||
use libimagentryutil::isa::Is;
|
||||
|
||||
use crate::bookmark::IsBookmark;
|
||||
use crate::bookmark::Bookmark;
|
||||
|
||||
pub trait BookmarkStore {
|
||||
|
||||
|
@ -45,7 +48,10 @@ impl BookmarkStore for Store {
|
|||
let uuid = uuid::Uuid::new_v4();
|
||||
id_for_uuid(&uuid)
|
||||
.and_then(|id| self.create(id))
|
||||
.and_then(|mut entry| entry.set_url(url).map(|_| (uuid, entry)))
|
||||
.and_then(|mut entry| {
|
||||
entry.set_isflag::<IsBookmark>()?;
|
||||
entry.set_url(url).map(|_| (uuid, entry))
|
||||
})
|
||||
}
|
||||
|
||||
fn get_bookmark_by_uuid<'a>(&'a self, uuid: &Uuid) -> Result<Option<FileLockEntry<'a>>> {
|
||||
|
|
Loading…
Reference in a new issue