Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbabcock committed Jan 20, 2025
1 parent 0c3720f commit 7645f0f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,14 @@ impl FrameError {
attr_obj.attribute, actor_obj_name
)?;
} else {
writeln!(f, "attribute: {}", context.objects.get(usize::from(attr_obj.object_id)).map_or("<unknown>", |v| v))?;
writeln!(
f,
"attribute: {}",
context
.objects
.get(usize::from(attr_obj.object_id))
.map_or("<unknown>", |v| v)
)?;

// No need for further context so we return early.
return Ok(());
Expand Down
8 changes: 4 additions & 4 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn parse_rdict(
}

let kind = rlp.parse_str()?;

// This size is normally the number of bytes a property takes up,
// but it can't be trusted, so we're ignoring it.
let _size = rlp.take_u32("property size")? as usize;
Expand All @@ -118,7 +118,8 @@ fn parse_rdict(
value: value.map(String::from),
})
}
ParserMode::Quirks => rlp.parse_text()
ParserMode::Quirks => rlp
.parse_text()
.map(|kind| HeaderProp::Byte { kind, value: None }),
},
"ArrayProperty" => array_property(rlp, mode),
Expand All @@ -134,8 +135,7 @@ fn parse_rdict(
.take_bytes::<8>()
.map(u64::from_le_bytes)
.map(HeaderProp::QWord),
"NameProperty" => rlp.parse_text()
.map(HeaderProp::Name),
"NameProperty" => rlp.parse_text().map(HeaderProp::Name),
"StrProperty" => rlp.parse_text().map(HeaderProp::Str),
"StructProperty" => {
let name = rlp.parse_str()?;
Expand Down
18 changes: 14 additions & 4 deletions src/network/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,10 +1453,20 @@ impl AttributeDecoder {
}
}

fn decode_logo_data(&self, bits: &mut LittleEndianReader<'_>) -> Result<Attribute, AttributeError> {
let logo_id = bits.read_u32().ok_or(AttributeError::NotEnoughDataFor("LogoData"))?;
let swap_colors = bits.read_bit().ok_or(AttributeError::NotEnoughDataFor("LogoData"))?;
Ok(Attribute::LogoData(LogoData { logo_id, swap_colors }))
fn decode_logo_data(
&self,
bits: &mut LittleEndianReader<'_>,
) -> Result<Attribute, AttributeError> {
let logo_id = bits
.read_u32()
.ok_or(AttributeError::NotEnoughDataFor("LogoData"))?;
let swap_colors = bits
.read_bit()
.ok_or(AttributeError::NotEnoughDataFor("LogoData"))?;
Ok(Attribute::LogoData(LogoData {
logo_id,
swap_colors,
}))
}
}

Expand Down

0 comments on commit 7645f0f

Please sign in to comment.