DescriptorBuilder

Struct DescriptorBuilder 

Source
pub struct DescriptorBuilder { /* private fields */ }
Expand description

Builder to construct descriptors with deterministic ordering.

use daedalus_data::descriptor::{DescriptorBuilder, GpuHints, MemoryLocation};
use daedalus_data::errors::DataResult;
use daedalus_data::model::{TypeExpr, Value, ValueType};

fn build_descriptor() -> DataResult<()> {
    let desc = DescriptorBuilder::new("example", "1.0.0")
        .label("Example")
        .settable(true)
        .type_expr(TypeExpr::Scalar(ValueType::String))
        .default(Value::String("hi".into()))
        .codec("json")
        .feature_flag("core")
        .gpu_hints(GpuHints { requires_gpu: false, preferred_memory: Some(MemoryLocation::Host) })
        .build()?;
    assert_eq!(desc.codecs, vec!["json"]);
    Ok(())
}

Implementations§

Source§

impl DescriptorBuilder

Source

pub fn new(id: impl Into<String>, version: impl Into<String>) -> Self

Source

pub fn label(self, label: impl Into<String>) -> Self

Source

pub fn settable(self, settable: bool) -> Self

Source

pub fn default(self, default: Value) -> Self

Source

pub fn schema(self, schema: impl Into<String>) -> Self

Source

pub fn codec(self, codec: impl Into<String>) -> Self

Source

pub fn converter(self, conv: impl Into<String>) -> Self

Source

pub fn feature_flag(self, flag: impl Into<String>) -> Self

Source

pub fn gpu_hints(self, hints: GpuHints) -> Self

Source

pub fn type_expr(self, ty: TypeExpr) -> Self

Source

pub fn build(self) -> DataResult<DataDescriptor>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.