Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@anweiss
Copy link
Owner

@anweiss anweiss commented Mar 24, 2022

Addresses #105 and #114

@anweiss anweiss self-assigned this Mar 24, 2022
@anweiss anweiss added bug Something isn't working enhancement New feature or request labels Mar 24, 2022
@anweiss anweiss added this to the v1.0.0 milestone Mar 24, 2022
@anweiss
Copy link
Owner Author

anweiss commented Mar 25, 2022

@itamarst FYSA, this PR introduces some API improvements per #105 so you can now do something like

let cddl_schema = CDDL::from_slice(
  r#"
    foo = {
      bar: tstr
    }
  "#.as_bytes(),
)
.unwrap();

let documents = [r#"{ "bar": "foo" }"#, r#"{ "bar": "foo2" }"#];

documents
  .iter()
  .all(|doc| cddl_schema.validate(doc.as_bytes(), None).is_ok());

Let me know what you think

@itamarst
Copy link
Contributor

I can probably create a branch off of your branch, will try that.

@itamarst
Copy link
Contributor

That is, create a branch of pycddl that uses branch of cddl, to try the new API.

@itamarst
Copy link
Contributor

I tested CDDL::from_slice with my current approach of parsing the schema for every validation. It works, simplified the code slightly.

@itamarst
Copy link
Contributor

(The lifetime requirements is still making interop with PyO3 hard, though, since it's explicitly not supported: PyO3/pyo3#502. So #104 is still blocker on keeping pre-parsed CDDL around.)

@itamarst
Copy link
Contributor

@anweiss
Copy link
Owner Author

anweiss commented Mar 30, 2022

Thanks for testing! Yea, I'll be working through #104 once I get this PR finished up.

@anweiss anweiss marked this pull request as ready for review April 15, 2022 15:35
@anweiss anweiss merged commit b91f289 into main Apr 15, 2022
@anweiss anweiss deleted the api-improvements branch April 15, 2022 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants