[−][src]Struct thyme::ContextBuilder
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]
&mut self,
theme: T
) -> Result<(), T::Error>
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]
&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>,
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]
&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>,
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]
&mut self,
id: T,
path: &Path
)
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]
&mut self,
id: T,
data: Vec<u8>,
dimensions: (u32, u32)
)
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]
self,
renderer: &mut R,
io: &mut I
) -> Result<Context, Error>
Auto Trait Implementations
impl !RefUnwindSafe for ContextBuilder
impl !Send for ContextBuilder
impl !Sync for ContextBuilder
impl Unpin for ContextBuilder
impl !UnwindSafe for ContextBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,