Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulate Metadata's data. #91

Merged
merged 1 commit into from Oct 20, 2019
Merged

Encapsulate Metadata's data. #91

merged 1 commit into from Oct 20, 2019

Conversation

sebpuetz
Copy link
Member

Restrict interface to Metadata's data, impl Deref(Mut) with
target toml::Value for Metadata.

@sebpuetz sebpuetz mentioned this pull request Oct 18, 2019
18 tasks
@@ -12,7 +13,30 @@ use crate::io::{Error, ErrorKind, ReadMetadata, Result};
///
/// finalfusion metadata in TOML format.
#[derive(Clone, Debug, PartialEq)]
pub struct Metadata(pub Value);
pub struct Metadata {
data: Value,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inner


impl Metadata {
/// Construct new `Metadata`.
pub fn new(data: Value) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a From counterpart would be nice here as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to implement TryFrom<V> where V: Serialize, but that fails because of blanket impls...

  --> src/chunks/metadata.rs:43:1
   |
43 | impl<V> TryFrom<V> for Metadata where V: Serialize {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: conflicting implementation in crate `core`:
           - impl<T, U> std::convert::TryFrom<U> for T
             where U: std::convert::Into<T>;

Restrict interface to Metadata's data, impl Deref(Mut) with
target toml::Value for Metadata.
@sebpuetz
Copy link
Member Author

Is this and #90 good to go?

@sebpuetz sebpuetz merged commit baaface into master Oct 20, 2019
@sebpuetz sebpuetz deleted the encapsulate-metadata branch October 20, 2019 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants