pub struct Project {
pub sprites: Vec<Sprite>,
pub stage: Stage,
}Expand description
The Project struct represents a Scratch 3.0 project.
It contains all the decoded data from a .sb3 file, including sprites and the stage.
Fields§
§sprites: Vec<Sprite>Contains all the sprites in the project.
stage: StageContains the stage of the project.
Implementations§
Source§impl Project
impl Project
Sourcepub fn new(
raw: RawProject,
zip: &mut ZipArchive<Cursor<Vec<u8>>>,
) -> Result<Self, DecodeError>
pub fn new( raw: RawProject, zip: &mut ZipArchive<Cursor<Vec<u8>>>, ) -> Result<Self, DecodeError>
Returns a new project from a RawProject and the zip archive.
§Errors
Returns DecodeError::Zip if there is an error reading the ZIP archive.
Returns DecodeError::NotFound if something expected is not found in the archive or in
the JSON data.
Sourcepub fn global_variables(&self) -> &HashMap<String, Variable>
pub fn global_variables(&self) -> &HashMap<String, Variable>
Returns a reference to the global variables from the stage.
§Example
let project = decoder.decode().unwrap();
let global_vars = project.global_variables();Sourcepub fn global_variables_mut(&mut self) -> &mut HashMap<String, Variable>
pub fn global_variables_mut(&mut self) -> &mut HashMap<String, Variable>
Returns a mutable reference to the global variables from the stage.
§Example
let mut project = decoder.decode().unwrap();
let mut global_vars = project.global_variables_mut();Sourcepub fn broadcasts(&self) -> Vec<Broadcast>
pub fn broadcasts(&self) -> Vec<Broadcast>
Returns all the broadcast messages in the project.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Project
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnwindSafe for Project
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more