Skip to content

Commit

Permalink
Add clarity comments to From<c_uint> for HostType and SchemeType
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleinmarb committed Aug 3, 2024
1 parent a1d277b commit a4f8712
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ impl From<c_uint> for HostType {

// Safety: Prior to transmuting we checked if value is bigger than 2
// and returned the default in that case.
unsafe { std::mem::transmute(value) }
//
// Mapping:
// - 0 => Domain
// - 1 => IPV4
// - 2 => IPV6
// - any other number maps to NotSpecial
unsafe { std::mem::transmute(value as u32) }
}
}

Expand All @@ -107,7 +113,17 @@ impl From<c_uint> for SchemeType {

// Safety: Prior to transmuting we checked if value is bigger than 6
// and returned the default in that case.
unsafe { std::mem::transmute(value) }
//
// Mapping:
// - 0 => Http
// - 1 => NotSpecial
// - 2 => Https
// - 3 => Ws
// - 4 => Ftp
// - 5 => Wss
// - 6 => File
// - any other number maps to NotSpecial
unsafe { std::mem::transmute(value as u32) }
}
}

Expand Down

0 comments on commit a4f8712

Please sign in to comment.