json_ld_context_processing_next/
processed.rs1use iref::IriBuf;
2use json_ld_core_next::Context;
3use rdf_types::BlankIdBuf;
4use std::ops;
5
6pub struct Processed<'l, T = IriBuf, B = BlankIdBuf> {
8 pub unprocessed: &'l json_ld_syntax_next::context::Context,
9 pub processed: Context<T, B>,
10}
11
12impl<'l, T, B> Processed<'l, T, B> {
13 pub fn new(
14 unprocessed: &'l json_ld_syntax_next::context::Context,
15 processed: Context<T, B>,
16 ) -> Self {
17 Self {
18 unprocessed,
19 processed,
20 }
21 }
22
23 pub fn unprocessed(&self) -> &'l json_ld_syntax_next::context::Context {
24 self.unprocessed
25 }
26
27 pub fn into_processed(self) -> Context<T, B> {
28 self.processed
29 }
30
31 pub fn as_ref(&self) -> ProcessedRef<'l, '_, T, B> {
32 ProcessedRef {
33 unprocessed: self.unprocessed,
34 processed: &self.processed,
35 }
36 }
37
38 pub fn into_owned(self) -> ProcessedOwned<T, B> {
39 ProcessedOwned {
40 unprocessed: self.unprocessed.clone(),
41 processed: self.processed,
42 }
43 }
44}
45
46impl<T, B> ops::Deref for Processed<'_, T, B> {
47 type Target = Context<T, B>;
48
49 fn deref(&self) -> &Self::Target {
50 &self.processed
51 }
52}
53
54impl<T, B> ops::DerefMut for Processed<'_, T, B> {
55 fn deref_mut(&mut self) -> &mut Self::Target {
56 &mut self.processed
57 }
58}
59
60pub struct ProcessedRef<'l, 'a, T, B> {
62 pub unprocessed: &'l json_ld_syntax_next::context::Context,
63 pub processed: &'a Context<T, B>,
64}
65
66impl<'l, 'a, T, B> ProcessedRef<'l, 'a, T, B> {
67 pub fn new(
68 unprocessed: &'l json_ld_syntax_next::context::Context,
69 processed: &'a Context<T, B>,
70 ) -> Self {
71 Self {
72 unprocessed,
73 processed,
74 }
75 }
76
77 pub fn unprocessed(&self) -> &'l json_ld_syntax_next::context::Context {
78 self.unprocessed
79 }
80
81 pub fn processed(&self) -> &'a Context<T, B> {
82 self.processed
83 }
84}
85
86pub struct ProcessedOwned<T, B> {
88 pub unprocessed: json_ld_syntax_next::context::Context,
89 pub processed: Context<T, B>,
90}
91
92impl<T, B> ProcessedOwned<T, B> {
93 pub fn new(
94 unprocessed: json_ld_syntax_next::context::Context,
95 processed: Context<T, B>,
96 ) -> Self {
97 Self {
98 unprocessed,
99 processed,
100 }
101 }
102
103 pub fn unprocessed(&self) -> &json_ld_syntax_next::context::Context {
104 &self.unprocessed
105 }
106
107 pub fn processed(&self) -> &Context<T, B> {
108 &self.processed
109 }
110
111 pub fn as_ref(&self) -> ProcessedRef<T, B> {
112 ProcessedRef {
113 unprocessed: &self.unprocessed,
114 processed: &self.processed,
115 }
116 }
117}