pub struct RawSketchwareProject {
pub project: String,
pub file: String,
pub library: String,
pub resource: String,
pub view: String,
pub logic: String,
pub resource_files: Option<Vec<ResourceFileWrapper>>,
}Expand description
Represents a raw (un-parsed) sketchware project
Fields§
§project: String§file: String§library: String§resource: String§view: String§logic: String§resource_files: Option<Vec<ResourceFileWrapper>>A list of resource files that belongs to this project
None means to automatically assign missing resources with a random id
Implementations§
Source§impl RawSketchwareProject
impl RawSketchwareProject
Sourcepub fn new(
project: String,
file: String,
library: String,
resource: String,
view: String,
logic: String,
resource_files: Vec<ResourceFileWrapper>,
) -> Self
pub fn new( project: String, file: String, library: String, resource: String, view: String, logic: String, resource_files: Vec<ResourceFileWrapper>, ) -> Self
Creates a RawSketchwareProject with the specified fields
Examples found in repository?
examples/api_demo1.rs (line 42)
9fn main() {
10 let mut args = std::env::args();
11 args.next();
12
13 let project = read(args.next().expect("File path of a project data file to parse")).expect("Invalid project path given");
14 let file = read(args.next().expect("File path of a file data file to parse")).expect("Invalid file path given");
15 let library = read(args.next().expect("File path of a library data file to parse")).expect("Invalid library path given");
16 let resource = read(args.next().expect("File path of a resource data file to parse")).expect("Invalid resource path given");
17 let view = read(args.next().expect("File path of a view data file to parse")).expect("Invalid view path given");
18 let logic = read(args.next().expect("File path of a logic data file to parse")).expect("Invalid logic path given");
19
20 // decrypt them
21
22 let project = swrs::decrypt_sw_encrypted(&project).expect("Unable to decrypt project");
23 let file = swrs::decrypt_sw_encrypted(&file).expect("Unable to decrypt file");
24 let library = swrs::decrypt_sw_encrypted(&library).expect("Unable to decrypt library");
25 let resource = swrs::decrypt_sw_encrypted(&resource).expect("Unable to decrypt resource");
26 let view = swrs::decrypt_sw_encrypted(&view).expect("Unable to decrypt view");
27 let logic = swrs::decrypt_sw_encrypted(&logic).expect("Unable to decrypt logic");
28
29 // turn them into strings
30
31 let project = String::from_utf8(project).expect("Invalid charset for project");
32 let file = String::from_utf8(file).expect("Invalid charset for file");
33 let library = String::from_utf8(library).expect("Invalid charset for library");
34 let resource = String::from_utf8(resource).expect("Invalid charset for resource");
35 let view = String::from_utf8(view).expect("Invalid charset for view");
36 let logic = String::from_utf8(logic).expect("Invalid charset for logic");
37
38 // and parse them
39
40 let sketchware_project = SketchwareProject::try_from(
41 ParsedSketchwareProject::parse_from(
42 RawSketchwareProject::new(project, file, library, resource, view, logic, vec![])
43 ).expect("Corrupted sketchware project")
44 ).expect("Corrupted sketchware project");
45
46 println!("Screens:");
47
48 for screen in sketchware_project.screens {
49 println!(" Screen {} or {}:", screen.layout_name, screen.java_name);
50 println!(" Events:");
51
52 for event in screen.events {
53 println!(" - Event {}, type: {:?}, blocks:", event.name, event.event_type);
54
55 fn print_blocks(indentation: u32, blocks: Blocks) {
56 for block in blocks {
57 println!("{}Block #{} opcode {}", " ".repeat(indentation as usize), block.op_code, block.content.to_string());
58
59 if let Some(blocks_ss1) = block.sub_stack1 {
60 println!("{}substack1: ", " ".repeat(indentation as usize));
61 print_blocks(indentation + 2, blocks_ss1);
62 }
63
64 if let Some(blocks_ss2) = block.sub_stack2 {
65 println!("{}substack2: ", " ".repeat(indentation as usize));
66 print_blocks(indentation + 2, blocks_ss2);
67 }
68 }
69
70 println!();
71 }
72
73 print_blocks(8, event.code);
74 }
75 }
76}Sourcepub fn new_wo_res(
project: String,
file: String,
library: String,
resource: String,
view: String,
logic: String,
) -> Self
pub fn new_wo_res( project: String, file: String, library: String, resource: String, view: String, logic: String, ) -> Self
Creates a RawSketchwareProject with the specified fields without the resource files, they will all be assigned to random ids
pub fn from_encrypted( project: Vec<u8>, file: Vec<u8>, library: Vec<u8>, resource: Vec<u8>, view: Vec<u8>, logic: Vec<u8>, resource_files: Vec<ResourceFileWrapper>, ) -> Result<Self, CryptoError>
Sourcepub fn from_encrypted_wo_res(
project: Vec<u8>,
file: Vec<u8>,
library: Vec<u8>,
resource: Vec<u8>,
view: Vec<u8>,
logic: Vec<u8>,
) -> Result<Self, CryptoError>
pub fn from_encrypted_wo_res( project: Vec<u8>, file: Vec<u8>, library: Vec<u8>, resource: Vec<u8>, view: Vec<u8>, logic: Vec<u8>, ) -> Result<Self, CryptoError>
Creates a RawSketchwareProject from encrypted sketchware project data without the resource files, they will all be assigned to random ids
Trait Implementations§
Source§impl Clone for RawSketchwareProject
impl Clone for RawSketchwareProject
Source§fn clone(&self) -> RawSketchwareProject
fn clone(&self) -> RawSketchwareProject
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 RawSketchwareProject
impl Debug for RawSketchwareProject
Source§impl PartialEq for RawSketchwareProject
impl PartialEq for RawSketchwareProject
Source§fn eq(&self, other: &RawSketchwareProject) -> bool
fn eq(&self, other: &RawSketchwareProject) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl TryInto<RawSketchwareProject> for SketchwareProject
impl TryInto<RawSketchwareProject> for SketchwareProject
Source§type Error = SketchwareProjectReconstructionError
type Error = SketchwareProjectReconstructionError
The type returned in the event of a conversion error.
Source§impl TryInto<RawSketchwareProject> for SketchwareProject
impl TryInto<RawSketchwareProject> for SketchwareProject
Source§type Error = SketchwareProjectReconstructionError
type Error = SketchwareProjectReconstructionError
The type returned in the event of a conversion error.
impl StructuralPartialEq for RawSketchwareProject
Auto Trait Implementations§
impl Freeze for RawSketchwareProject
impl RefUnwindSafe for RawSketchwareProject
impl Send for RawSketchwareProject
impl Sync for RawSketchwareProject
impl Unpin for RawSketchwareProject
impl UnsafeUnpin for RawSketchwareProject
impl UnwindSafe for RawSketchwareProject
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