Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Important: If you're upgrading snforge to version 0.48.0 or later, please read the 0.48.0 Migration Guide.

File

Trait for handling file operations in Starknet Foundry.

trait FileTrait {
    fn new(path: ByteArray) -> File;
}

â„šī¸ Info

Specific rules must be followed for snforge to correctly parse JSON and plain text files.

Read file format rules for more.

Example

File content:

'Hello Starknet!'
'Let's code in Cairo!'
"Example byte array"

Test code:

use snforge_std::fs::FileTrait;

#[test]
fn file_trait_example() {
    // Create an instance of `File` to be used later
    let _file = FileTrait::new("data/hello_starknet.txt");
}