-
Notifications
You must be signed in to change notification settings - Fork 144
RUST-1998 Remove lossy utf8 as a decoder option #550
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
Changes from all commits
9009481
90913c2
36a564f
c2083d4
a70c452
affe749
64afd63
8679191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,7 +265,14 @@ impl<'a> RawElement<'a> { | |
}) | ||
} | ||
|
||
pub(crate) fn value_utf8_lossy(&self) -> Result<Option<Utf8LossyBson<'a>>> { | ||
pub fn value_utf8_lossy(&self) -> Result<RawBson> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opted to expose this method rather than the lower-level |
||
match self.value_utf8_lossy_inner()? { | ||
Some(v) => Ok(v.into()), | ||
None => Ok(self.value()?.to_raw_bson()), | ||
} | ||
} | ||
|
||
pub(crate) fn value_utf8_lossy_inner(&self) -> Result<Option<Utf8LossyBson<'a>>> { | ||
Ok(Some(match self.kind { | ||
ElementType::String => Utf8LossyBson::String(self.read_utf8_lossy()), | ||
ElementType::JavaScriptCode => Utf8LossyBson::JavaScriptCode(self.read_utf8_lossy()), | ||
|
@@ -452,3 +459,22 @@ pub(crate) struct Utf8LossyJavaScriptCodeWithScope<'a> { | |
pub(crate) code: String, | ||
pub(crate) scope: &'a RawDocument, | ||
} | ||
|
||
impl<'a> From<Utf8LossyBson<'a>> for RawBson { | ||
fn from(value: Utf8LossyBson<'a>) -> Self { | ||
match value { | ||
Utf8LossyBson::String(s) => RawBson::String(s), | ||
Utf8LossyBson::JavaScriptCode(s) => RawBson::JavaScriptCode(s), | ||
Utf8LossyBson::JavaScriptCodeWithScope(Utf8LossyJavaScriptCodeWithScope { | ||
code, | ||
scope, | ||
}) => RawBson::JavaScriptCodeWithScope(super::RawJavaScriptCodeWithScope { | ||
code, | ||
scope: scope.to_raw_document_buf(), | ||
}), | ||
Utf8LossyBson::Symbol(s) => RawBson::Symbol(s), | ||
Utf8LossyBson::DbPointer(p) => RawBson::DbPointer(p), | ||
Utf8LossyBson::RegularExpression(r) => RawBson::RegularExpression(r), | ||
} | ||
} | ||
} |
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.
This is completely unrelated but I happened to notice it and figured we should remove deprecated methods while we're doing a major version release. I did a grep and didn't find any others.