Struct strfile::strfile::Strfile
[−]
[src]
pub struct Strfile { pub version: u32, pub number_of_strings: u32, pub longest_length: u32, pub shortest_length: u32, pub flags: u32, pub delim: u8, pub offsets: Vec<u32>, }
Fields
version: u32
Version of the header.
number_of_strings: u32
Number of strings stored in fortune file.
longest_length: u32
Length of the longest quote.
shortest_length: u32
Length of the shortest quote.
flags: u32
Bit field for flags.
delim: u8
Delimeter used for separating quotes.
offsets: Vec<u32>
Byte offsets to beginnings of the strings.
Methods
impl Strfile
[src]
fn is_flag_set(&self, mask: Flags) -> bool
Check if flag is set.
Examples:
use strfile::{Strfile, Flags}; fn main() { let header = Strfile::parse("fortune.dat".to_owned()).unwrap(); println!("ROT13: {}", if header.is_flag_set(Flags::Rotated) { "yes" } else { "no" }); }
fn read_quotes(&self, filename: String) -> Result<Vec<String>, Error>
fn parse(filename: String) -> Result<Strfile, Error>
Read strfile header contents from a file.
Example usage:
use strfile::Strfile; pub fn main() { let header = Strfile::parse("fortune.dat".to_owned()).unwrap():; println!("Header contents: {:?}", header); }