Skip to main content

render_container

Function render_container 

Source
pub fn render_container(
    app: &DidNostr,
    owner: &DidNostr,
    grant: &ContainerGrant,
) -> OfferedContainer
Expand description

Renders one container’s offered authorisation.

owner is the pod’s owner; the container IRI is root-relative, </pods/<owner>/<path>>, as the profile ACL writes its IRIs.

§Examples

use stratum_node_core::{render_container, ContainerGrant, DidNostr};

let app = DidNostr::from_hex(&"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5")?;
let owner = DidNostr::from_hex(&"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")?;
let grant: ContainerGrant =
    serde_json::from_str(r#"{"path":"reports/","modes":["Read","Write"],"operations":["GET","PUT"]}"#)?;
let offered = render_container(&app, &owner, &grant);
assert!(offered.turtle.contains(&format!("acl:agent <{app}>")));
assert!(offered.turtle.contains(&format!("acl:default </pods/{}/reports/>", owner.to_hex())));
assert!(offered.turtle.contains("acl:mode acl:Read, acl:Write ."));
assert!(!offered.turtle.contains("acl:accessTo"));