-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes leakage of GDALDataType::Type in RasterBand. #334
Conversation
* master: Hold back geo-types version; deprecations addressed in georust#339 Fixes deprecations introduced in geo-types v0.7.8. Hold back chrono version, as it's addressed in georust#336 Update .cargo/config.toml Fix deprecations from chrono 0.4.23.
unsafe { gdal_sys::GDALGetRasterDataType(self.c_rasterband) } | ||
pub fn band_type(&self) -> GdalDataType { | ||
let ordinal = unsafe { gdal_sys::GDALGetRasterDataType(self.c_rasterband) }; | ||
ordinal.try_into().unwrap_or(GdalDataType::Unknown) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looking at the code in the browser, can we call GdalType::datatype()
here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lnicola Not sure what you mean... GdalType::datatype()
would be to get the datatype most closely associated with a static primitive. In this case, we're getting a c_int
from C-GDAL and need to map that into the GdalDataType
enum. But perhaps I'm missing what you're suggesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically ordinal.datatype()
instead of ordinal.try_into().unwrap_or(GdalDataType::Unknown)
. Maybe it doesn't work for c_int
, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, it doesn't work. GdalType
is a (wierd) type-level trait, with no self
parameter:
Line 330 in 029b95a
fn datatype() -> GdalDataType { |
In Scala I'd have called this an "evidence" trait. So <u8>::datatype()
exists, but 3u8.datatype()
does not.
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
@bors d+ |
bors r+ |
CHANGES.md
if knowledge of this change could be valuable to users.Also fixes related rustdoc, and cleans up
gdal_sys
test warnings.Closes #333