pub struct DecoderBuilder { /* private fields */ }Expand description
Implementations§
Source§impl DecoderBuilder
impl DecoderBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new DecoderBuilder instance with no source specified.
Sourcepub fn use_file(self, path: impl Into<PathBuf>) -> Self
pub fn use_file(self, path: impl Into<PathBuf>) -> Self
Specifies the source as a file path.
§Example
let builder = DecoderBuilder::new()
.use_file("path/to/project.sb3");Sourcepub fn use_bytes(self, bytes: &[u8]) -> Self
pub fn use_bytes(self, bytes: &[u8]) -> Self
Specifies the source as in-memory bytes.
§Example
let builder = DecoderBuilder::new()
.use_bytes(include_bytes!("path/to/project.sb3"));Sourcepub fn build(self) -> Result<Decoder, BuilderError>
pub fn build(self) -> Result<Decoder, BuilderError>
Builds the Decoder from the specified source.
§Example
let decoder = match builder.build() {
Ok(decoder) => decoder,
Err(e) => panic!("Failed to build decoder: {}", e),
};§Errors
Returns BuilderError::FileRead if there is an error reading the file.
Returns BuilderError::NoSource if no source was specified.
Returns BuilderError::Decode if there is an error creating the decoder.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DecoderBuilder
impl RefUnwindSafe for DecoderBuilder
impl Send for DecoderBuilder
impl Sync for DecoderBuilder
impl Unpin for DecoderBuilder
impl UnwindSafe for DecoderBuilder
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().