My stab at CI (#66)
This commit is contained in:
@@ -618,25 +618,24 @@ impl Asset for ImageAssetLoader {
|
||||
async move {
|
||||
let bytes = match source.clone() {
|
||||
Resource::Path(uri) => fs::read(uri.as_ref())?,
|
||||
Resource::Uri(uri) => {
|
||||
use anyhow::Context as _;
|
||||
Resource::Uri(uri) => {
|
||||
use anyhow::Context as _;
|
||||
|
||||
let response = client
|
||||
.get(uri.as_ref(), true)
|
||||
.await
|
||||
.with_context(|| format!("loading image asset from {uri:?}"))?;
|
||||
if !response.status.is_success() {
|
||||
let mut error_body =
|
||||
String::from_utf8_lossy(&response.body).into_owned();
|
||||
let first_line = error_body.lines().next().unwrap_or("").trim_end();
|
||||
error_body.truncate(first_line.len());
|
||||
return Err(ImageCacheError::BadStatus {
|
||||
uri,
|
||||
status: response.status,
|
||||
body: error_body,
|
||||
});
|
||||
}
|
||||
response.body
|
||||
let response = client
|
||||
.get(uri.as_ref(), true)
|
||||
.await
|
||||
.with_context(|| format!("loading image asset from {uri:?}"))?;
|
||||
if !response.status.is_success() {
|
||||
let mut error_body = String::from_utf8_lossy(&response.body).into_owned();
|
||||
let first_line = error_body.lines().next().unwrap_or("").trim_end();
|
||||
error_body.truncate(first_line.len());
|
||||
return Err(ImageCacheError::BadStatus {
|
||||
uri,
|
||||
status: response.status,
|
||||
body: error_body,
|
||||
});
|
||||
}
|
||||
response.body
|
||||
}
|
||||
Resource::Embedded(path) => {
|
||||
let data = asset_source.load(&path).ok().flatten();
|
||||
|
||||
@@ -40,12 +40,12 @@ impl Clone for SurfaceSource {
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SurfaceSource {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match *self {
|
||||
#[cfg(target_os = "macos")]
|
||||
SurfaceSource::Surface(ref buf) => f.debug_tuple("Surface").field(buf).finish(),
|
||||
SurfaceSource::Surface(ref buf) => _f.debug_tuple("Surface").field(buf).finish(),
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
SurfaceSource::Texture { size, .. } => f
|
||||
SurfaceSource::Texture { size, .. } => _f
|
||||
.debug_struct("Texture")
|
||||
.field("size", &size)
|
||||
.finish_non_exhaustive(),
|
||||
@@ -124,27 +124,27 @@ impl Element for Surface {
|
||||
&mut self,
|
||||
_global_id: Option<&GlobalElementId>,
|
||||
_inspector_id: Option<&InspectorElementId>,
|
||||
bounds: Bounds<Pixels>,
|
||||
_bounds: Bounds<Pixels>,
|
||||
_: &mut Self::RequestLayoutState,
|
||||
_: &mut Self::PrepaintState,
|
||||
window: &mut Window,
|
||||
_window: &mut Window,
|
||||
_: &mut App,
|
||||
) {
|
||||
match self.source {
|
||||
#[cfg(target_os = "macos")]
|
||||
SurfaceSource::Surface(ref surface) => {
|
||||
let size = crate::size(surface.get_width().into(), surface.get_height().into());
|
||||
let new_bounds = self.object_fit.get_bounds(bounds, size);
|
||||
let new_bounds = self.object_fit.get_bounds(_bounds, size);
|
||||
// TODO: Add support for corner_radii
|
||||
window.paint_surface(new_bounds, surface.clone());
|
||||
_window.paint_surface(new_bounds, surface.clone());
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
SurfaceSource::Texture {
|
||||
ref texture,
|
||||
ref size,
|
||||
} => {
|
||||
let new_bounds = self.object_fit.get_bounds(bounds, *size);
|
||||
window.paint_surface(new_bounds, Arc::clone(texture), *size);
|
||||
let new_bounds = self.object_fit.get_bounds(_bounds, *size);
|
||||
_window.paint_surface(new_bounds, Arc::clone(texture), *size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user