Skip to main content

ifc_style/texture/
image.rs

1//! `IfcImageTexture` URL projection.
2
3use ifc_model::EntityId;
4
5use crate::error::StyleResult;
6use crate::texture::SurfaceTexture;
7use crate::view::Record;
8
9/// Borrowed projection of `IfcImageTexture`: a raster image referenced by URL
10/// rather than embedded inline.
11#[derive(Debug, Clone, Copy)]
12pub struct ImageTexture<'m, 's> {
13    record: Record<'m, 's>,
14}
15
16impl<'m, 's> ImageTexture<'m, 's> {
17    pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
18        Self { record }
19    }
20
21    /// The entity id of this `IfcImageTexture`.
22    pub fn id(&self) -> EntityId {
23        self.record.id
24    }
25
26    /// The base `IfcSurfaceTexture` attributes shared with other texture kinds.
27    pub fn surface_texture(&self) -> SurfaceTexture<'m, 's> {
28        SurfaceTexture::from_record(self.record)
29    }
30
31    /// The `URLReference` attribute: the image's location. Mandatory.
32    pub fn url_reference(&self) -> StyleResult<&'m str> {
33        self.record.required_text("URLReference")
34    }
35}