Make Application and Sandbox return a Result
This commit is contained in:
parent
faa12382d4
commit
c1f79b40cf
40 changed files with 166 additions and 58 deletions
7
graphics/src/error.rs
Normal file
7
graphics/src/error.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/// A graphical error that occurred while running an application.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// A suitable graphics adapter or device could not be found
|
||||
#[error("a suitable graphics adapter or device could not be found")]
|
||||
AdapterNotFound,
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#![forbid(rust_2018_idioms)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
mod antialiasing;
|
||||
mod error;
|
||||
mod primitive;
|
||||
mod renderer;
|
||||
mod transformation;
|
||||
|
|
@ -29,6 +30,7 @@ pub use widget::*;
|
|||
pub use antialiasing::Antialiasing;
|
||||
pub use backend::Backend;
|
||||
pub use defaults::Defaults;
|
||||
pub use error::Error;
|
||||
pub use layer::Layer;
|
||||
pub use primitive::Primitive;
|
||||
pub use renderer::Renderer;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Color, Viewport};
|
||||
use crate::{Color, Error, Viewport};
|
||||
use iced_native::mouse;
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ pub trait Compositor: Sized {
|
|||
/// Creates a new [`Backend`].
|
||||
///
|
||||
/// [`Backend`]: trait.Backend.html
|
||||
fn new(settings: Self::Settings) -> (Self, Self::Renderer);
|
||||
fn new(settings: Self::Settings) -> Result<(Self, Self::Renderer), Error>;
|
||||
|
||||
/// Crates a new [`Surface`] for the given window.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Color, Size, Viewport};
|
||||
use crate::{Color, Error, Size, Viewport};
|
||||
use iced_native::mouse;
|
||||
|
||||
use core::ffi::c_void;
|
||||
|
|
@ -41,7 +41,7 @@ pub trait GLCompositor: Sized {
|
|||
unsafe fn new(
|
||||
settings: Self::Settings,
|
||||
loader_function: impl FnMut(&str) -> *const c_void,
|
||||
) -> (Self, Self::Renderer);
|
||||
) -> Result<(Self, Self::Renderer), Error>;
|
||||
|
||||
/// Returns the amount of samples that should be used when configuring
|
||||
/// an OpenGL context for this [`Compositor`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue