Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Feb 12, 2024
1 parent 986fbed commit 9b5f6cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions crates/state/src/custom_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ impl Display for CursorReference {
#[derive(Debug, Clone, PartialEq)]
pub enum AttributesBytes {
Dynamic(Arc<Vec<u8>>),
Static(&'static [u8])
Static(&'static [u8]),
}

impl AttributesBytes {
pub fn as_slice(&self) -> &[u8] {
match self {
Self::Dynamic(bytes) => bytes.as_slice(),
Self::Static(bytes) => bytes
Self::Static(bytes) => bytes,
}
}
}
Expand Down Expand Up @@ -153,7 +153,9 @@ impl FromAnyValue for CustomAttributeValues {

/// Transform some bytes (e.g: raw image, raw svg) into attribute data
pub fn bytes_to_data(bytes: &[u8]) -> AttributeValue {
AttributeValue::any_value(CustomAttributeValues::Bytes(AttributesBytes::Dynamic(Arc::new(bytes.to_vec()))))
AttributeValue::any_value(CustomAttributeValues::Bytes(AttributesBytes::Dynamic(
Arc::new(bytes.to_vec()),
)))
}

/// Transform some static bytes (e.g: raw image, raw svg) into attribute data
Expand Down
6 changes: 4 additions & 2 deletions crates/state/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use dioxus_native_core_macro::partial_derive_state;
use torin::scaled::Scaled;

use crate::{
parsing::ExtSplit, AttributesBytes, Border, BorderAlignment, CornerRadius, CustomAttributeValues, Fill, OverflowMode, Parse, Shadow
parsing::ExtSplit, AttributesBytes, Border, BorderAlignment, CornerRadius,
CustomAttributeValues, Fill, OverflowMode, Parse, Shadow,
};

#[derive(Default, Debug, Clone, PartialEq, Component)]
Expand Down Expand Up @@ -143,7 +144,8 @@ impl State<CustomAttributeValues> for Style {
}
"svg_content" => {
let text = attr.value.as_text();
style.svg_data = text.map(|v| AttributesBytes::Dynamic(Arc::new(v.as_bytes().to_owned())));
style.svg_data = text
.map(|v| AttributesBytes::Dynamic(Arc::new(v.as_bytes().to_owned())));
}
"overflow" => {
if let Some(value) = attr.value.as_text() {
Expand Down

0 comments on commit 9b5f6cc

Please sign in to comment.