[][src]Struct thyme::ContextBuilder

pub struct ContextBuilder { /* fields omitted */ }

Structure to register resources and ultimately build the main Thyme Context.

You pass resources to it to register them with Thyme. Once this process is complete, call build to create your Context.

Implementations

impl ContextBuilder[src]

pub fn with_defaults() -> ContextBuilder[src]

Creates a new ContextBuilder, using the default BuildOptions

Example

    let mut context_builder = thyme::ContextBuilder::with_defaults();
    context_builder.register_theme(theme)?;
    ...

pub fn new(options: BuildOptions) -> ContextBuilder[src]

Creates a new ContextBuilder, using the specified BuildOptions

pub fn register_theme<'a, T: Deserializer<'a>>(
    &mut self,
    theme: T
) -> Result<(), T::Error>
[src]

Sets the theme for this context. The theme for your UI will be deserialized from theme. For example, theme could be a serde_json Value or serde_yaml Value. See the crate root for a discussion of the theme format. If this method is called multiple times, only the last theme is used

pub fn register_theme_from_file<T, E, F>(
    &mut self,
    path: &Path,
    f: F
) -> Result<(), Error> where
    T: 'static + for<'de> Deserializer<'de>,
    E: 'static + Error,
    F: 'static + Fn(&str) -> Result<T, E>, 
[src]

Sets the theme for this context by reading from the file at the specified path. The files are first read to a string and then passed to the function f, which returns a serde Deserializable object. That object is then deserialized as the theme. See register_theme

pub fn register_theme_from_files<T, E, F>(
    &mut self,
    paths: &[&Path],
    f: F
) -> Result<(), Error> where
    T: 'static + for<'de> Deserializer<'de>,
    E: 'static + Error,
    F: 'static + Fn(&str) -> Result<T, E>, 
[src]

Sets the theme for this context by reading from the specified list of files. The files are each read into a string and then concatenated together. The string is passed to the function f which returns a serde Deserializable object, which is finally deserialized into the theme. See register_theme

pub fn register_font_from_file<T: Into<String>>(&mut self, id: T, path: &Path)[src]

Registers the font data located in the file at the specified path with Thyme via the specified id. See register_font

pub fn register_font<T: Into<String>>(&mut self, id: T, data: Vec<u8>)[src]

Registers the font data for use with Thyme via the specified id. The data must consist of the full binary for a valid TTF or OTF file. Once the font has been registered, it can be accessed in your theme file via the font source.

pub fn register_texture_from_file<T: Into<String>>(
    &mut self,
    id: T,
    path: &Path
)
[src]

Reads a texture from the specified image file. See register_texture. Requires you to enable the image feature in Cargo.toml to enable the dependancy on the image crate.

pub fn register_texture<T: Into<String>>(
    &mut self,
    id: T,
    data: Vec<u8>,
    dimensions: (u32, u32)
)
[src]

Registers the image data for use with Thyme via the specified id. The data must consist of raw binary image data in RGBA format, with 4 bytes per pixel. The data must start at the bottom-left hand corner pixel and progress left-to-right and bottom-to-top. data.len() must equal dimensions.0 * dimensions.1 * 4 Once the image has been registered, it can be accessed in your theme file via the image source.

pub fn build<R: Renderer, I: IO>(
    self,
    renderer: &mut R,
    io: &mut I
) -> Result<Context, Error>
[src]

Consumes this builder and releases the borrows on the Renderer and IO, so they can be used further. Builds a Context.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.