[−][src]Struct jomini::Scalar
Single value encapsulating windows-1252 data.
Since windows-1252 is a single byte character encoding, a scalar will never fail to be created.
use jomini::Scalar; let v1 = Scalar::new(b"a"); assert_eq!(v1.to_utf8(), "a");
Implementations
impl<'a> Scalar<'a>
[src]
pub fn new(data: &'a [u8]) -> Scalar<'a>
[src]
Create a new scalar backed by windows-1252 encoded byte slice
pub fn view_data(&self) -> &[u8]
[src]
View the underlying windows-1252 encoded data
pub fn to_f64(&self) -> Result<f64, ScalarError>
[src]
Try converting the scalar to f64
pub fn to_bool(&self) -> Result<bool, ScalarError>
[src]
Try converting the scalar to f64
pub fn to_i64(&self) -> Result<i64, ScalarError>
[src]
Try converting the scalar to i64
pub fn to_u64(&self) -> Result<u64, ScalarError>
[src]
Try converting the scalar to u64
pub fn to_utf8(&self) -> Cow<'a, str>
[src]
Convert scalar data into utf8. Will allocate if the string is not utf8.
use jomini::Scalar; let v1 = Scalar::new(b"a"); assert_eq!(v1.to_utf8(), "a"); let v2 = Scalar::new(&[255][..]); assert_eq!(v2.to_utf8(), "ÿ");
pub fn to_utf8_owned(&self) -> String
[src]
Convert scalar data into an owned string
use jomini::Scalar; let v1 = Scalar::new(b"a"); assert_eq!(v1.to_utf8(), String::from("a")); let v2 = Scalar::new(&[255][..]); assert_eq!(v2.to_utf8(), String::from("ÿ"));
pub fn is_ascii(&self) -> bool
[src]
Returns if the scalar contains only ascii values
use jomini::Scalar; let v1 = Scalar::new(b"a"); assert!(v1.is_ascii()); let v2 = Scalar::new(&[255][..]); assert!(!v2.is_ascii());
Trait Implementations
impl<'a> Clone for Scalar<'a>
[src]
impl<'a> Copy for Scalar<'a>
[src]
impl<'a> Debug for Scalar<'a>
[src]
impl<'a> Display for Scalar<'a>
[src]
impl<'a> PartialEq<Scalar<'a>> for Scalar<'a>
[src]
impl<'a> StructuralPartialEq for Scalar<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Scalar<'a>
impl<'a> Send for Scalar<'a>
impl<'a> Sync for Scalar<'a>
impl<'a> Unpin for Scalar<'a>
impl<'a> UnwindSafe for Scalar<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,