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 = DeviceSQLString::new("foo".to_owned()).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: String) -> Result<Self, StringError>
pub fn new(string: String) -> 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>
Read
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>
Read
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>
Read
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>
Read
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>
Read
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>
Read
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>
Read
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>
Write
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>
Write
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>
Write
Self
to the writer assuming little-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>
Write
Self
to the writer using the given arguments. Read moreSource§impl Clone for DeviceSQLString
impl Clone for DeviceSQLString
Source§fn clone(&self) -> DeviceSQLString
fn clone(&self) -> DeviceSQLString
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DeviceSQLString
impl Debug for DeviceSQLString
Source§impl Default for DeviceSQLString
impl Default for DeviceSQLString
Source§impl PartialEq for DeviceSQLString
impl PartialEq for DeviceSQLString
Source§impl ReadEndian for DeviceSQLString
impl ReadEndian for DeviceSQLString
Source§impl WriteEndian for DeviceSQLString
impl WriteEndian for DeviceSQLString
impl Eq for DeviceSQLString
impl StructuralPartialEq for DeviceSQLString
Auto Trait Implementations§
impl Freeze for DeviceSQLString
impl RefUnwindSafe for DeviceSQLString
impl Send for DeviceSQLString
impl Sync for DeviceSQLString
impl Unpin for DeviceSQLString
impl UnwindSafe for DeviceSQLString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more