-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from azriel91/feature/interactive-tags
- Loading branch information
Showing
20 changed files
with
1,557 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
use indexmap::{IndexMap, IndexSet}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::common::{EdgeId, TagId}; | ||
|
||
/// Tags associated with each edge. `IndexMap<EdgeId, IndexSet<TagId>>` newtype. | ||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct EdgeTagsSet(IndexMap<EdgeId, IndexSet<TagId>>); | ||
|
||
impl EdgeTagsSet { | ||
/// Returns a new `EdgeTags` map. | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
/// Returns a new `EdgeTags` map with the given preallocated | ||
/// capacity. | ||
pub fn with_capacity(capacity: usize) -> Self { | ||
Self(IndexMap::with_capacity(capacity)) | ||
} | ||
|
||
/// Returns the underlying map. | ||
pub fn into_inner(self) -> IndexMap<EdgeId, IndexSet<TagId>> { | ||
self.0 | ||
} | ||
} | ||
|
||
impl Deref for EdgeTagsSet { | ||
type Target = IndexMap<EdgeId, IndexSet<TagId>>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for EdgeTagsSet { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl From<IndexMap<EdgeId, IndexSet<TagId>>> for EdgeTagsSet { | ||
fn from(inner: IndexMap<EdgeId, IndexSet<TagId>>) -> Self { | ||
Self(inner) | ||
} | ||
} | ||
|
||
impl FromIterator<(EdgeId, IndexSet<TagId>)> for EdgeTagsSet { | ||
fn from_iter<I: IntoIterator<Item = (EdgeId, IndexSet<TagId>)>>(iter: I) -> Self { | ||
Self(IndexMap::from_iter(iter)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
use indexmap::IndexMap; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::common::{AnyId, TagId}; | ||
|
||
/// Each tag and the items associated with it. `IndexMap<TagId, Vec<AnyId>>` | ||
/// newtype. | ||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct TagItems(IndexMap<TagId, Vec<AnyId>>); | ||
|
||
impl TagItems { | ||
/// Returns a new `TagItems` map. | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
/// Returns a new `TagItems` map with the given preallocated | ||
/// capacity. | ||
pub fn with_capacity(capacity: usize) -> Self { | ||
Self(IndexMap::with_capacity(capacity)) | ||
} | ||
|
||
/// Returns the underlying map. | ||
pub fn into_inner(self) -> IndexMap<TagId, Vec<AnyId>> { | ||
self.0 | ||
} | ||
} | ||
|
||
impl Deref for TagItems { | ||
type Target = IndexMap<TagId, Vec<AnyId>>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for TagItems { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl From<IndexMap<TagId, Vec<AnyId>>> for TagItems { | ||
fn from(inner: IndexMap<TagId, Vec<AnyId>>) -> Self { | ||
Self(inner) | ||
} | ||
} | ||
|
||
impl FromIterator<(TagId, Vec<AnyId>)> for TagItems { | ||
fn from_iter<I: IntoIterator<Item = (TagId, Vec<AnyId>)>>(iter: I) -> Self { | ||
Self(IndexMap::from_iter(iter)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
use indexmap::IndexMap; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::common::TagId; | ||
|
||
/// Each tag and its name. `IndexMap<TagId, String>` newtype. | ||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct TagNames(IndexMap<TagId, String>); | ||
|
||
impl TagNames { | ||
/// Returns a new `TagNames` map. | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
/// Returns a new `TagNames` map with the given preallocated | ||
/// capacity. | ||
pub fn with_capacity(capacity: usize) -> Self { | ||
Self(IndexMap::with_capacity(capacity)) | ||
} | ||
|
||
/// Returns the underlying map. | ||
pub fn into_inner(self) -> IndexMap<TagId, String> { | ||
self.0 | ||
} | ||
} | ||
|
||
impl Deref for TagNames { | ||
type Target = IndexMap<TagId, String>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for TagNames { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl From<IndexMap<TagId, String>> for TagNames { | ||
fn from(inner: IndexMap<TagId, String>) -> Self { | ||
Self(inner) | ||
} | ||
} | ||
|
||
impl FromIterator<(TagId, String)> for TagNames { | ||
fn from_iter<I: IntoIterator<Item = (TagId, String)>>(iter: I) -> Self { | ||
Self(IndexMap::from_iter(iter)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
use indexmap::IndexMap; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{common::TagId, theme::ThemeStyles}; | ||
|
||
/// Each tag and styles for the items associated with it. `IndexMap<TagId, | ||
/// ThemeStyles>` newtype. | ||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct TagStyles(IndexMap<TagId, ThemeStyles>); | ||
|
||
impl TagStyles { | ||
/// Returns a new `TagStyles` map. | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
/// Returns a new `TagStyles` map with the given preallocated | ||
/// capacity. | ||
pub fn with_capacity(capacity: usize) -> Self { | ||
Self(IndexMap::with_capacity(capacity)) | ||
} | ||
|
||
/// Returns the underlying map. | ||
pub fn into_inner(self) -> IndexMap<TagId, ThemeStyles> { | ||
self.0 | ||
} | ||
} | ||
|
||
impl Deref for TagStyles { | ||
type Target = IndexMap<TagId, ThemeStyles>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for TagStyles { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl From<IndexMap<TagId, ThemeStyles>> for TagStyles { | ||
fn from(inner: IndexMap<TagId, ThemeStyles>) -> Self { | ||
Self(inner) | ||
} | ||
} | ||
|
||
impl FromIterator<(TagId, ThemeStyles)> for TagStyles { | ||
fn from_iter<I: IntoIterator<Item = (TagId, ThemeStyles)>>(iter: I) -> Self { | ||
Self(IndexMap::from_iter(iter)) | ||
} | ||
} |
Oops, something went wrong.