MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / parse_schema_fragment

Method parse_schema_fragment

CedarJavaFFI/src/helpers.rs:78–99  ·  view source on GitHub ↗

Return a [`crate::SchemaFragment`], which can be printed with `.to_string()` and converted to JSON with `.to_json()`.

(
        self,
    )

Source from the content-addressed store, hash-verified

76 /// Return a [`crate::SchemaFragment`], which can be printed with `.to_string()`
77 /// and converted to JSON with `.to_json()`.
78 pub(super) fn parse_schema_fragment(
79 self,
80 ) -> Result<(SchemaFragment, Box<dyn Iterator<Item = SchemaWarning>>), miette::Report> {
81 match self {
82 Self::Cedar(str) => SchemaFragment::from_cedarschema_str(&str)
83 .map(|(sch, warnings)| {
84 (
85 sch,
86 Box::new(warnings) as Box<dyn Iterator<Item = SchemaWarning>>,
87 )
88 })
89 .wrap_err("failed to parse schema from string"),
90 Self::Json(val) => SchemaFragment::from_json_value(val.into())
91 .map(|sch| {
92 (
93 sch,
94 Box::new(std::iter::empty()) as Box<dyn Iterator<Item = SchemaWarning>>,
95 )
96 })
97 .wrap_err("failed to parse schema from JSON"),
98 }
99 }
100}
101
102impl LevelValidationCall {

Callers 1

parseMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected