pub struct SnapshotResult { /* private fields */ }

Implementations§

Returns an empty set of flags.

Returns the set containing all flags.

Returns the raw value of the flags currently stored.

Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).

Safety

The caller of the bitflags! macro can chose to allow or disallow extra bits for their bitflags type.

The caller of from_bits_unchecked() has to ensure that all bits correspond to a defined flag or that extra bits are valid for this bitflags type.

Returns true if no flags are currently stored.

Returns true if all flags are currently set.

Returns true if there are flags common to both self and other.

Returns true if all of the flags in other are contained within self.

Inserts the specified flags in-place.

Examples found in repository?
src/z80/saver.rs (line 45)
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
fn init_z80_header<C: Cpu>(
        header: &mut Header,
        version: Z80Version,
        cpu: &C,
        border: BorderColor,
        issue: ReadEarMode,
        joystick: Option<JoystickModel>,
        result: &mut SnapshotResult
    )
{
    let r = cpu.get_r();
    let flags1 = if version == Z80Version::V1 {
        Flags1::MEM_COMPRESSED
    }
    else {
        Flags1::empty()
    }
    .with_border_color(border)
    .with_refresh_high_bit(r);
    // TODO: flags1.set(Flags1::BASIC_SAMROM, samrom_basic_switched_in);
    let mut flags2 = Flags2::empty()
    .with_interrupt_mode(cpu.get_im())
    .with_issue2_emulation(issue);
    if !joystick.map(|joy| flags2.insert_joystick_model(joy)).unwrap_or(false) {
        result.insert(SnapshotResult::JOYSTICK_NSUP);
    }

    let (a, f) = cpu.get_reg2(StkReg16::AF);
    header.a = a;
    header.f = f;
    header.bc = cpu.get_reg16(StkReg16::BC).to_le_bytes();
    header.hl = cpu.get_reg16(StkReg16::HL).to_le_bytes();
    header.pc = if version == Z80Version::V1 { cpu.get_pc() } else { 0 }.to_le_bytes();
    header.sp = cpu.get_sp().to_le_bytes();
    header.i = cpu.get_i();
    header.r7 = r & ((!0) >> 1);
    header.flags1 = flags1.bits();
    header.de = cpu.get_reg16(StkReg16::DE).to_le_bytes();
    header.bc_alt = cpu.get_alt_reg16(StkReg16::BC).to_le_bytes();
    header.de_alt = cpu.get_alt_reg16(StkReg16::DE).to_le_bytes();
    header.hl_alt = cpu.get_alt_reg16(StkReg16::HL).to_le_bytes();
    let (a_alt, f_alt) = cpu.get_alt_reg2(StkReg16::AF);
    header.a_alt = a_alt;
    header.f_alt = f_alt;
    header.iy = cpu.get_index16(Prefix::Yfd).to_le_bytes();
    header.ix = cpu.get_index16(Prefix::Xdd).to_le_bytes();
    let (iff1, iff2) = cpu.get_iffs();
    header.iff1 = if iff1 { !0 } else { 0 };
    header.iff2 = if iff2 { !0 } else { 0 };
    header.flags2 = flags2.bits();
}

fn select_hw_model_v2<S: SnapshotCreator>(
        model: ComputerModel,
        ext: Extensions,
        snapshot: &S,
        result: &mut SnapshotResult
    ) -> Result<(u8, bool)>
{
    use ComputerModel::*;
    if ext.intersects(Extensions::PLUS_D) && snapshot.is_plus_d_rom_paged_in()
       || ext.intersects(Extensions::DISCIPLE) && snapshot.is_disciple_rom_paged_in()
       || ext.intersects(Extensions::TR_DOS) && snapshot.is_tr_dos_rom_paged_in()
       || ext.contains(Extensions::IF1|Extensions::SAM_RAM) && snapshot.is_interface1_rom_paged_in()
    {
        return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a version 2 snapshot with the external ROM paged in"))
    }
    if (ext&!(Extensions::IF1|Extensions::SAM_RAM)) != Extensions::NONE
       || ext.contains(Extensions::IF1|Extensions::SAM_RAM)
    {
        result.insert(SnapshotResult::EXTENSTION_NSUP);
    }
    Ok(match model {
        Spectrum16 if ext.intersects(Extensions::SAM_RAM) => (2, true),
        Spectrum16 if ext.intersects(Extensions::IF1) => (1, true),
        Spectrum16 => (0, true),
        Spectrum48 if ext.intersects(Extensions::SAM_RAM) => (2, false),
        Spectrum48 if ext.intersects(Extensions::IF1) => (1, false),
        Spectrum48 => (0, false),
        SpectrumNTSC => {
            result.insert(SnapshotResult::MODEL_NSUP);
            (if ext.intersects(Extensions::SAM_RAM) { 2 }
             else { ext.intersects(Extensions::IF1) as u8 }, false)
        }
        Spectrum128 if ext.intersects(Extensions::IF1) => (4, false),
        Spectrum128 => (3, false),
        SpectrumPlus2 if ext.intersects(Extensions::IF1) => (4, true),
        SpectrumPlus2 => (3, true),
        SpectrumPlus2A => (7, true),
        SpectrumPlus3 => (7, false),
        SpectrumPlus3e => {
            result.insert(SnapshotResult::MODEL_NSUP);
            (7, false)
        }
        SpectrumSE => {
            return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a snapshot of SpectrumSE"))
        }
        TimexTC2048|TimexTC2068|TimexTS2068 if ext.intersects(Extensions::IF1)
                             && snapshot.is_interface1_rom_paged_in() => {
            return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a snapshot of Timex + IF1 with IF1 ROM paged in"))
        }
        TimexTC2048 => (14, false),
        TimexTC2068 => (15, false),
        TimexTS2068 => (128, false),
    })
}

fn select_hw_model_v3<S: SnapshotCreator>(
        model: ComputerModel,
        ext: Extensions,
        snapshot: &S,
        result: &mut SnapshotResult
    ) -> Result<(u8, bool)>
{
    use ComputerModel::*;
    if ext.intersects(Extensions::TR_DOS) && snapshot.is_tr_dos_rom_paged_in()
       || ext.contains(Extensions::IF1|Extensions::SAM_RAM) && snapshot.is_interface1_rom_paged_in()
    {
        return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a version 3 snapshot with the external ROM paged in"))
    }
    if ext.contains(Extensions::IF1|Extensions::SAM_RAM) {
        result.insert(SnapshotResult::EXTENSTION_NSUP);
    }
    Ok(match model {
        Spectrum16 if ext.intersects(Extensions::SAM_RAM) => (2, true),
        Spectrum16 if ext.intersects(Extensions::IF1) => (1, true),
        Spectrum16 if ext.intersects(Extensions::PLUS_D|Extensions::DISCIPLE) => (3, true),
        Spectrum16 => (0, true),
        Spectrum48 if ext.intersects(Extensions::SAM_RAM) => (2, false),
        Spectrum48 if ext.intersects(Extensions::IF1) => (1, false),
        Spectrum48 if ext.intersects(Extensions::PLUS_D|Extensions::DISCIPLE) => (3, false),
        Spectrum48 => (0, false),
        SpectrumNTSC => {
            result.insert(SnapshotResult::MODEL_NSUP);
            (if ext.intersects(Extensions::SAM_RAM) { 2 }
            else if ext.intersects(Extensions::IF1) { 1 }
            else if ext.intersects(Extensions::PLUS_D|Extensions::DISCIPLE) { 3 }
            else { 0 }, false)
        }
        Spectrum128 if ext.intersects(Extensions::IF1) => (5, false),
        Spectrum128 if ext.intersects(Extensions::PLUS_D|Extensions::DISCIPLE) => (6, false),
        Spectrum128 => (4, false),
        SpectrumPlus2 if ext.intersects(Extensions::IF1) => (5, true),
        SpectrumPlus2 if ext.intersects(Extensions::PLUS_D|Extensions::DISCIPLE) => (6, true),
        SpectrumPlus2 => (4, true),
        SpectrumPlus2A => (7, true),
        SpectrumPlus3 => (7, false),
        SpectrumPlus3e => {
            result.insert(SnapshotResult::MODEL_NSUP);
            (7, false)
        }
        SpectrumSE => {
            return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a snapshot of SpectrumSE"))
        }
        TimexTC2048|TimexTC2068|TimexTS2068 if (ext.intersects(Extensions::IF1) && snapshot.is_interface1_rom_paged_in())
                             || (ext.intersects(Extensions::PLUS_D) && snapshot.is_plus_d_rom_paged_in())
                             || (ext.intersects(Extensions::DISCIPLE) && snapshot.is_disciple_rom_paged_in())
                             => {
            return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a snapshot of Timex with extension ROM paged in"))
        }
        TimexTC2048 => (14, false),
        TimexTC2068 => (15, false),
        TimexTS2068 => (128, false),
    })
}

type HwModelSelector<S> = fn(
        ComputerModel, Extensions, &S, &mut SnapshotResult
    ) -> Result<(u8, bool)>;

fn init_z80_header_ex<S: SnapshotCreator, C: Cpu>(
        head_ex: &mut HeaderEx,
        cpu: C,
        model: ComputerModel,
        ext: Extensions,
        snapshot: &S,
        select_hw_model: HwModelSelector<S>,
        result: &mut SnapshotResult
    ) -> Result<()>
{
    use ComputerModel::*;
    head_ex.pc = cpu.get_pc().to_le_bytes();
    let (hw_mode, alt_hw) = select_hw_model(model, ext, snapshot, result)?;
    let mut flags3 = Flags3::empty();
    flags3.set(Flags3::ALT_HW_MODE, alt_hw);
    head_ex.hw_mode = hw_mode;
    let res = if let Some(res) = snapshot.ay_state(Ay3_891xDevice::Ay128k) {
        if snapshot.ay_state(Ay3_891xDevice::FullerBox).is_some()
           || snapshot.ay_state(Ay3_891xDevice::Melodik).is_some()
        {
            result.insert(SnapshotResult::SOUND_CHIP_NSUP);
        }
        Some(res)
    }
    else if let Some(res) = snapshot.ay_state(Ay3_891xDevice::FullerBox) {
        flags3.insert(Flags3::AY_SOUND_EMU|Flags3::AY_FULLER_BOX);
        Some(res)
    }
    else if let Some(res) = snapshot.ay_state(Ay3_891xDevice::Melodik) {
        flags3.insert(Flags3::AY_SOUND_EMU);
        Some(res)
    }
    else {
        snapshot.ay_state(Ay3_891xDevice::Timex)
    };
    if let Some((ay_sel_reg, ay_regs)) = res {
        head_ex.ay_sel_reg = ay_sel_reg.into();
        head_ex.ay_regs = *ay_regs;
    }

    head_ex.port1 = match model {
        Spectrum128|SpectrumPlus2|SpectrumPlus2A|SpectrumPlus3|SpectrumPlus3e|
        SpectrumSE => snapshot.ula128_flags().bits(),
        TimexTC2048|TimexTC2068|TimexTS2068 => snapshot.timex_memory_banks(),
        _ => 0
    };
    head_ex.ifrom = match model {
        TimexTC2048|TimexTS2068|TimexTC2068 => {
            if ext.intersects(Extensions::IF1|Extensions::PLUS_D|Extensions::DISCIPLE) {
                result.insert(SnapshotResult::EXTENSTION_NSUP);
            }
            snapshot.timex_flags().bits()
        }
        _ if ext.intersects(Extensions::IF1) && snapshot.is_interface1_rom_paged_in() => {
            !0
        }
        _ => 0
    };
    head_ex.flags3 = flags3.bits();
    Ok(())
}

fn save_ram_pages<W: Write, S: SnapshotCreator, I: Iterator<Item=(u8, usize)>>(
        mut wr: W,
        snapshot: &S,
        pages: I
    ) -> Result<()>
{
    let mut buf = Vec::with_capacity(0x1000);
    for (ptype, page) in pages {
        buf.clear();
        let mem_slice = snapshot.memory_ref(MemoryRange::Ram(page * PAGE_SIZE..(page + 1) * PAGE_SIZE))?;
        compress_write_all(mem_slice, &mut buf)?;
        let (mem_head, slice) = match buf.len().try_into() {
            Ok(core::u16::MAX)|Err(..) => {
                (MemoryHeader::new(core::u16::MAX, ptype), mem_slice)
            }
            Ok(length) => (MemoryHeader::new(length, ptype), &buf[..]),
        };
        mem_head.write_struct(wr.by_ref())?;
        wr.write_all(slice)?;
    }
    wr.flush()
}

fn save_all_v2v3<W: Write, S: SnapshotCreator>(
        version: Z80Version,
        snapshot: &S,
        model: ComputerModel,
        header: &Header,
        head_ex: &HeaderEx,
        mut wr: W
    ) -> Result<()>
{
    use ComputerModel::*;
    header.write_struct(wr.by_ref())?;
    let ex_len: u16 = match version {
        Z80Version::V2 => 23,
        Z80Version::V3 if head_ex.port2 != 0 => 55,
        Z80Version::V3 => 54,
        _ => unreachable!()
    };
    wr.write_all(&ex_len.to_le_bytes()[..])?;
    head_ex.write_struct_with_limit(wr.by_ref(), ex_len as usize)?;

    match model {
        Spectrum16 => {
            save_ram_pages(wr, snapshot, iter::once((8, 0)))
        }
        Spectrum48|SpectrumNTSC|TimexTC2048|TimexTS2068|TimexTC2068 => {
            save_ram_pages(wr, snapshot,
                [(8, 0), (4, 1), (5, 2)].iter().copied())
        }
        Spectrum128|SpectrumPlus2|SpectrumPlus2A|SpectrumPlus3|SpectrumPlus3e => {
            save_ram_pages(wr, snapshot,
                (0..8).map(|page| (page as u8 + 3, page))
            )
        }
        _ => unreachable!()
    }
}

fn get_nmos_cpu(cpu: CpuModel, result: &mut SnapshotResult) -> Z80NMOS {
    match cpu {
        CpuModel::NMOS(cpu) => cpu,
        CpuModel::CMOS(cpu) => {
            result.insert(SnapshotResult::CPU_MODEL_NSUP);
            cpu.into_flavour()
        },
        CpuModel::BM1(cpu) => {
            result.insert(SnapshotResult::CPU_MODEL_NSUP);
            cpu.into_flavour()
        }
    }
}

/// Saves a **Z80** file version 1 into `wr` from the provided reference to a `snapshot` struct
/// implementing [SnapshotCreator].
///
/// # Errors
/// This function may return an error from attempts to write the file or if for some reason
/// a snapshot could not be created.
pub fn save_z80v1<C: SnapshotCreator, W: Write>(
        snapshot: &C,
        mut wr: W
    ) -> Result<SnapshotResult>
{
    use ComputerModel::*;
    let mut result = SnapshotResult::OK;

    let model = snapshot.model();
    match model {
        Spectrum48 => {},
        Spectrum16|SpectrumNTSC|TimexTC2048 => {
            result.insert(SnapshotResult::MODEL_NSUP);
        }
        _ => return Err(io::Error::new(io::ErrorKind::InvalidInput,
                        "Z80: can't create a version 1 snapshot of this computer model"))
    };
    let extensions = snapshot.extensions();
    if let Err(bad_ext) = model.validate_extensions(extensions) {
        return Err(io::Error::new(io::ErrorKind::InvalidInput,
            format!("Z80: the model {} can't be saved with {}", model, bad_ext)))
    }

    if extensions.intersects(Extensions::IF1) && snapshot.is_interface1_rom_paged_in()
       || extensions.intersects(Extensions::PLUS_D) && snapshot.is_plus_d_rom_paged_in()
       || extensions.intersects(Extensions::DISCIPLE) && snapshot.is_disciple_rom_paged_in()
       || extensions.intersects(Extensions::TR_DOS) && snapshot.is_tr_dos_rom_paged_in()
    {
        return Err(io::Error::new(io::ErrorKind::InvalidInput,
                "Z80: can't create a version 1 snapshot with the external ROM paged in"))
    }
    if extensions != Extensions::NONE {
        result.insert(SnapshotResult::EXTENSTION_NSUP);
    }

    let cpu = get_nmos_cpu(snapshot.cpu(), &mut result);
    let border = snapshot.border_color();
    let issue = snapshot.issue();
    let joystick = snapshot.joystick();

    if snapshot.ay_state(Ay3_891xDevice::Ay128k).is_some()
       || snapshot.ay_state(Ay3_891xDevice::Melodik).is_some()
       || snapshot.ay_state(Ay3_891xDevice::FullerBox).is_some()
       || snapshot.ay_state(Ay3_891xDevice::Timex).is_some()
    {
        result.insert(SnapshotResult::SOUND_CHIP_NSUP);
    }

    let mut header = Header::default();
    init_z80_header(
        &mut header,
        Z80Version::V1,
        &cpu,
        border,
        issue,
        joystick,
        &mut result
    );

    header.write_struct(wr.by_ref())?;
    let is_16k = model == ComputerModel::Spectrum16;
    let ramend = if is_16k { 0x4000 } else { 0xC000 };
    let mem_slice = snapshot.memory_ref(MemoryRange::Ram(0..ramend))?;
    compress_write_all(mem_slice, wr.by_ref())?;
    if is_16k {
        compress_repeat_write_all(!0, 0x8000, wr.by_ref())?;
    }

    wr.write_all(MEMORY_V1_TERM)?;
    wr.flush()?;
    Ok(result)
}
More examples
Hide additional examples
src/sna.rs (line 313)
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
pub fn save_sna<C: SnapshotCreator, W: Write>(
        snapshot: &C,
        mut wr: W
    ) -> Result<SnapshotResult>
{
    use ComputerModel::*;
    let mut result = SnapshotResult::KEYB_ISSUE_NSUP;
    let model = snapshot.model();
    let is_128 = match model {
        Spectrum48 => false,
        Spectrum128 => true,
        SpectrumPlus2|SpectrumPlus2A|SpectrumPlus3|SpectrumPlus3e|SpectrumSE => {
            result.insert(SnapshotResult::MODEL_NSUP);
            true
        }
        Spectrum16|SpectrumNTSC|TimexTC2048|TimexTC2068|TimexTS2068 => {
            result.insert(SnapshotResult::MODEL_NSUP);
            false
        }
    };

    let extensions = snapshot.extensions();
    if extensions.intersects(Extensions::IF1) && snapshot.is_interface1_rom_paged_in()
       || extensions.intersects(Extensions::PLUS_D) && snapshot.is_plus_d_rom_paged_in()
    {
        return Err(Error::new(ErrorKind::InvalidInput,
                "SNA: can't create a snapshot with the external ROM paged in"))
    }
    if extensions != Extensions::NONE && extensions != Extensions::TR_DOS {
        result.insert(SnapshotResult::EXTENSTION_NSUP);
    }

    let cpu = match snapshot.cpu() {
        CpuModel::NMOS(cpu) => cpu,
        CpuModel::CMOS(cpu) => {
            result.insert(SnapshotResult::CPU_MODEL_NSUP);
            cpu.into_flavour()
        },
        CpuModel::BM1(cpu) => {
            result.insert(SnapshotResult::CPU_MODEL_NSUP);
            cpu.into_flavour()
        }
    };

    if !is_cpu_safe_for_snapshot(&cpu) {
        return Err(Error::new(ErrorKind::InvalidInput, "SNA: can't safely snapshot the CPU state"))
    }

    let mut sna = make_header(&cpu);
    sna.border = snapshot.border_color().into();

    if snapshot.joystick().is_some() {
        result.insert(SnapshotResult::JOYSTICK_NSUP);
    }

    if is_128 || snapshot.ay_state(Ay3_891xDevice::Melodik).is_some()
              || snapshot.ay_state(Ay3_891xDevice::FullerBox).is_some()
              || snapshot.ay_state(Ay3_891xDevice::Timex).is_some() {
        result.insert(SnapshotResult::SOUND_CHIP_NSUP);
    }

    if !is_128 {
        return save_sna48(snapshot, cpu, model == ComputerModel::Spectrum16, sna, wr, result)
    }

    let memflags = snapshot.ula128_flags();
    let mut sna_ext = SnaHeader128 {
        pc: cpu.get_pc().to_le_bytes(),
        port_data: memflags.bits(),
        ..Default::default()
    };

    if extensions.intersects(Extensions::TR_DOS) {
        sna_ext.trdos_rom = snapshot.is_tr_dos_rom_paged_in().into();
    }

    sna.write_struct(wr.by_ref())?;

    let last_page: usize = memflags.last_ram_page_bank();
    let index48 = [5,2,last_page];
    for page in index48.iter() {
        wr.write_all(
            snapshot.memory_ref(MemoryRange::Ram(page * PAGE_SIZE..(page + 1) * PAGE_SIZE))?
        )?;
    }

    sna_ext.write_struct(wr.by_ref())?;

    for page in (0..8).filter(|n| !index48.contains(n) && *n != last_page) {
        wr.write_all(
            snapshot.memory_ref(MemoryRange::Ram(page * PAGE_SIZE..(page + 1) * PAGE_SIZE))?
        )?;
    }

    wr.flush()?;
    Ok(result)
}

Removes the specified flags in-place.

Toggles the specified flags in-place.

Inserts or removes the specified flags depending on the passed value.

Returns the intersection between the flags in self and other.

Specifically, the returned set contains only the flags which are present in both self and other.

This is equivalent to using the & operator (e.g. ops::BitAnd), as in flags & other.

Returns the union of between the flags in self and other.

Specifically, the returned set contains all flags which are present in either self or other, including any which are present in both (see Self::symmetric_difference if that is undesirable).

This is equivalent to using the | operator (e.g. ops::BitOr), as in flags | other.

Returns the difference between the flags in self and other.

Specifically, the returned set contains all flags present in self, except for the ones present in other.

It is also conceptually equivalent to the “bit-clear” operation: flags & !other (and this syntax is also supported).

This is equivalent to using the - operator (e.g. ops::Sub), as in flags - other.

Returns the symmetric difference between the flags in self and other.

Specifically, the returned set contains the flags present which are present in self or other, but that are not present in both. Equivalently, it contains the flags present in exactly one of the sets self and other.

This is equivalent to using the ^ operator (e.g. ops::BitXor), as in flags ^ other.

Returns the complement of this set of flags.

Specifically, the returned set contains all the flags which are not set in self, but which are allowed for this type.

Alternatively, it can be thought of as the set difference between Self::all() and self (e.g. Self::all() - self)

This is equivalent to using the ! operator (e.g. ops::Not), as in !flags.

Trait Implementations§

Formats the value using the given formatter.

Returns the intersection between the two sets of flags.

The resulting type after applying the & operator.

Disables all flags disabled in the set.

Returns the union of the two sets of flags.

The resulting type after applying the | operator.

Adds the set of flags.

Returns the left flags, but with all the right flags toggled.

The resulting type after applying the ^ operator.

Toggles the set of flags.

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Formats the value using the given formatter.

Returns the complement of this set of flags.

The resulting type after applying the ! operator.
Formats the value using the given formatter.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the set difference of the two sets of flags.

The resulting type after applying the - operator.

Disables all flags enabled in the set.

Formats the value using the given formatter.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert to S a sample type from self.
Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.