while self.0.pop_if(|c| *c == b' ').is_some() {}
}
- pub fn with_encoding(self, encoding: &'static Encoding) -> EncodedString {
+ pub fn with_encoding(self, encoding: &'static Encoding) -> OwnedEncodedString {
EncodedString {
bytes: self,
encoding,
}
}
-impl From<EncodedString> for OwnedRawString {
- fn from(value: EncodedString) -> Self {
+impl From<OwnedEncodedString> for OwnedRawString {
+ fn from(value: OwnedEncodedString) -> Self {
value.bytes
}
}
/// A string value.
String(
/// The value, in the variable's encoding.
- EncodedString,
+ OwnedEncodedString,
),
}
/// Returns the string inside this datum, or `None` if this is a numeric
/// datum.
- pub fn as_string(&self) -> Option<&EncodedString> {
+ pub fn as_string(&self) -> Option<&OwnedEncodedString> {
match self {
Self::Number(_) => None,
Self::String(s) => Some(s),
/// Returns the string inside this datum as a mutable borrow, or `None` if
/// this is a numeric datum.
- pub fn as_string_mut(&mut self) -> Option<&mut EncodedString> {
+ pub fn as_string_mut(&mut self) -> Option<&mut OwnedEncodedString> {
match self {
Self::Number(_) => None,
Self::String(s) => Some(s),
impl From<&str> for EncodedDatum {
fn from(value: &str) -> Self {
- Self::String(EncodedString::from(value))
+ Self::String(OwnedEncodedString::from(value))
}
}
/// A string value.
String(
/// The value, in the variable's encoding.
- EncodedString<&'a BorrowedRawString>,
+ BorrowedEncodedString<'a>,
),
}
///
/// The string is not guaranteed to be valid in the encoding.
#[derive(Copy, Clone, Debug)]
-pub struct EncodedString<R = OwnedRawString> {
+pub struct EncodedString<R> {
/// The bytes of the string.
bytes: R,
}
}
-impl EncodedString {
+impl OwnedEncodedString {
pub fn resize(&mut self, new_len: usize) -> Result<(), ()> {
match new_len.cmp(&self.len()) {
Ordering::Less => {
}
}
-impl From<&str> for EncodedString {
+impl From<&str> for OwnedEncodedString {
fn from(value: &str) -> Self {
Self {
bytes: RawString(value.into()),
}
}
-impl Serialize for EncodedString {
+impl Serialize for OwnedEncodedString {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
use crate::{
calendar::{calendar_gregorian_to_offset, DateError},
- data::{BorrowedEncodedString, Datum, EncodedString, OwnedDatum},
+ data::{BorrowedEncodedString, Datum, OwnedDatum, OwnedEncodedString},
endian::{Endian, Parse},
format::{DateTemplate, Decimals, Settings, TemplateItem, Type},
settings::{EndianSettings, Settings as PsppSettings},
#[derive(Clone, Debug)]
pub struct ParseError {
type_: Type,
- input: EncodedString,
+ input: OwnedEncodedString,
kind: ParseErrorKind,
}