pub mod tokens;
mod binding;
mod connectable;
mod preview;
mod schema;
mod traits;
pub use binding::MaterialBindingAPI;
pub use connectable::base_name;
pub use preview::{read_preview_surface, Channel, ReadPreviewSurface};
pub use schema::{Material, NodeGraph, Shader};
pub use traits::Connectable;
use tokens::*;
macro_rules! impl_shade_schema {
(connectable $ty:ident) => {
impl $crate::usd::SchemaBase for $ty {
const KIND: $crate::usd::SchemaKind = $crate::usd::SchemaKind::ConcreteTyped;
fn prim(&self) -> &$crate::usd::Prim {
&self.0
}
}
impl $crate::schemas::shade::Connectable for $ty {}
};
(single_api $ty:ident) => {
impl $crate::usd::SchemaBase for $ty {
const KIND: $crate::usd::SchemaKind = $crate::usd::SchemaKind::SingleApplyApi;
fn prim(&self) -> &$crate::usd::Prim {
&self.0
}
}
};
}
pub(crate) use impl_shade_schema;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ImplementationSource {
#[default]
Id,
SourceAsset,
SourceCode,
}
impl ImplementationSource {
pub fn as_token(self) -> &'static str {
match self {
ImplementationSource::Id => IMPL_SOURCE_ID,
ImplementationSource::SourceAsset => IMPL_SOURCE_SOURCE_ASSET,
ImplementationSource::SourceCode => IMPL_SOURCE_SOURCE_CODE,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
IMPL_SOURCE_ID => ImplementationSource::Id,
IMPL_SOURCE_SOURCE_ASSET => ImplementationSource::SourceAsset,
IMPL_SOURCE_SOURCE_CODE => ImplementationSource::SourceCode,
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Connectability {
#[default]
Full,
InterfaceOnly,
}
impl Connectability {
pub fn as_token(self) -> &'static str {
match self {
Connectability::Full => CONNECTABILITY_FULL,
Connectability::InterfaceOnly => CONNECTABILITY_INTERFACE_ONLY,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
CONNECTABILITY_FULL => Connectability::Full,
CONNECTABILITY_INTERFACE_ONLY => Connectability::InterfaceOnly,
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum BindingStrength {
#[default]
WeakerThanDescendants,
StrongerThanDescendants,
}
impl BindingStrength {
pub fn as_token(self) -> &'static str {
match self {
BindingStrength::WeakerThanDescendants => STRENGTH_WEAKER_THAN_DESCENDANTS,
BindingStrength::StrongerThanDescendants => STRENGTH_STRONGER_THAN_DESCENDANTS,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
STRENGTH_WEAKER_THAN_DESCENDANTS => BindingStrength::WeakerThanDescendants,
STRENGTH_STRONGER_THAN_DESCENDANTS => BindingStrength::StrongerThanDescendants,
_ => return None,
})
}
}
crate::schemas::common::impl_token_value!(ImplementationSource, Connectability, BindingStrength);