(&self, access_ty: &TypedResourceIndex)
| 105 | |
| 106 | impl TypedResource { |
| 107 | pub(super) fn rep(&self, access_ty: &TypedResourceIndex) -> Result<u32> { |
| 108 | match (self, access_ty) { |
| 109 | (Self::Host(rep), TypedResourceIndex::Host(_)) => Ok(*rep), |
| 110 | (Self::Host(_), expected) => bail!(ResourceTypeMismatch { |
| 111 | expected: *expected, |
| 112 | found: "host resource", |
| 113 | }), |
| 114 | (Self::Component { rep, ty }, TypedResourceIndex::Component { ty: expected, .. }) => { |
| 115 | if ty == expected { |
| 116 | Ok(*rep) |
| 117 | } else { |
| 118 | bail!(ResourceTypeMismatch { |
| 119 | expected: *access_ty, |
| 120 | found: "a different guest-defined resource", |
| 121 | }) |
| 122 | } |
| 123 | } |
| 124 | (Self::Component { .. }, expected) => bail!(ResourceTypeMismatch { |
| 125 | expected: *expected, |
| 126 | found: "guest-defined resource", |
| 127 | }), |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /// An index used to access a resource. |
no test coverage detected