pub struct DeviceSQLString(/* private fields */);Expand description
Encapsulates the intrinsics of the format used by DeviceSQL strings
Once A DeviceSQLString has been constructed, there is no way to change it.
use rekordcrate::pdb::string::DeviceSQLString;
use binrw::{BinWrite, BinRead};
let string = "foo".parse::<DeviceSQLString>().unwrap();
let binary = vec![0x9, 0x66, 0x6F, 0x6F];
let mut writer = binrw::io::Cursor::new(vec![]);
string.write(&mut writer)?;
assert_eq!(&binary, writer.get_ref());
let mut reader = binrw::io::Cursor::new(binary);
let parsed = DeviceSQLString::read(&mut reader)?;
assert_eq!(parsed, string);Implementations§
Source§impl DeviceSQLString
impl DeviceSQLString
Sourcepub fn new(string: &str) -> Result<Self, StringError>
pub fn new(string: &str) -> Result<Self, StringError>
Initializes a DeviceSQLString from a plain Rust std::string::String
Sourcepub fn new_isrc(string: String) -> Result<Self, StringError>
pub fn new_isrc(string: String) -> Result<Self, StringError>
Creates a DeviceSQLString containing an ISRC instead of an expected string
The DeviceSQL Database as used by rekordbox has a strange oddity
where it serializes strings containing a tracks ISRC (International
Standard Recording Code) in an unexpected format, if this is desired,
use this constructor function instead of DeviceSQLString::new.
Sourcepub fn into_string(self) -> Result<String, StringError>
pub fn into_string(self) -> Result<String, StringError>
Extract the Rust string from the DeviceSQLString.
Consumes itself in the process.
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Create an empty DeviceSQLString.
Should be used to construct known empty strings.
Trait Implementations§
Source§impl BinRead for DeviceSQLString
impl BinRead for DeviceSQLString
Source§fn read_options<R: Read + Seek>(
__binrw_generated_var_reader: &mut R,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<Self>
§fn read<R>(reader: &mut R) -> Result<Self, Error>
fn read<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments. Read more§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
big-endian byte order. Read more§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
little-endian byte order. Read more§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T from the reader assuming native-endian byte order. Read more§fn read_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader using the given arguments. Read more§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader, assuming big-endian byte order, using the
given arguments. Read more§fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader, assuming little-endian byte order, using
the given arguments. Read moreSource§impl BinWrite for DeviceSQLString
impl BinWrite for DeviceSQLString
Source§fn write_options<W: Write + Seek>(
&self,
__binrw_generated_var_writer: &mut W,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<()>
§fn write<W>(&self, writer: &mut W) -> Result<(), Error>
fn write<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer using default arguments. Read more§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming big-endian byte order. Read more§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming little-endian byte order. Read more§fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming native-endian byte order. Read more§fn write_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self to the writer using the given arguments. Read more§fn write_be_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self to the writer, assuming big-endian byte order, using the
given arguments. Read moreSource§impl Clone for DeviceSQLString
impl Clone for DeviceSQLString
Source§fn clone(&self) -> DeviceSQLString
fn clone(&self) -> DeviceSQLString
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DeviceSQLString
impl Debug for DeviceSQLString
Source§impl Default for DeviceSQLString
impl Default for DeviceSQLString
Source§impl Display for DeviceSQLString
impl Display for DeviceSQLString
Source§impl FromStr for DeviceSQLString
support "somestr".parse().
ISRCs are an edge case that need to be constructed
using DeviceSQLString::new_isrc
impl FromStr for DeviceSQLString
support "somestr".parse().
ISRCs are an edge case that need to be constructed
using DeviceSQLString::new_isrc