Struct spectrusty_formats::snapshot::SnapshotResult
source · pub struct SnapshotResult { /* private fields */ }
Implementations§
source§impl SnapshotResult
impl SnapshotResult
pub const OK: Self = _
pub const MODEL_NSUP: Self = _
pub const EXTENSTION_NSUP: Self = _
pub const CPU_MODEL_NSUP: Self = _
pub const JOYSTICK_NSUP: Self = _
pub const SOUND_CHIP_NSUP: Self = _
pub const KEYB_ISSUE_NSUP: Self = _
sourcepub const fn from_bits(bits: u64) -> Option<Self>
pub const fn from_bits(bits: u64) -> Option<Self>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
sourcepub const fn from_bits_truncate(bits: u64) -> Self
pub const fn from_bits_truncate(bits: u64) -> Self
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
sourcepub const unsafe fn from_bits_unchecked(bits: u64) -> Self
pub const unsafe fn from_bits_unchecked(bits: u64) -> Self
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.
sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true
if there are flags common to both self
and other
.
sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true
if all of the flags in other
are contained within self
.
sourcepub fn insert(&mut self, other: Self)
pub fn insert(&mut self, other: Self)
Inserts the specified flags in-place.
Examples found in repository?
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
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)
}
sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Inserts or removes the specified flags depending on the passed value.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
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
.
sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
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
.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
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
.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
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
.
sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
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§
source§impl Binary for SnapshotResult
impl Binary for SnapshotResult
source§impl BitAnd<SnapshotResult> for SnapshotResult
impl BitAnd<SnapshotResult> for SnapshotResult
source§impl BitAndAssign<SnapshotResult> for SnapshotResult
impl BitAndAssign<SnapshotResult> for SnapshotResult
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
Disables all flags disabled in the set.
source§impl BitOr<SnapshotResult> for SnapshotResult
impl BitOr<SnapshotResult> for SnapshotResult
source§fn bitor(self, other: SnapshotResult) -> Self
fn bitor(self, other: SnapshotResult) -> Self
Returns the union of the two sets of flags.
§type Output = SnapshotResult
type Output = SnapshotResult
|
operator.source§impl BitOrAssign<SnapshotResult> for SnapshotResult
impl BitOrAssign<SnapshotResult> for SnapshotResult
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Adds the set of flags.
source§impl BitXor<SnapshotResult> for SnapshotResult
impl BitXor<SnapshotResult> for SnapshotResult
source§impl BitXorAssign<SnapshotResult> for SnapshotResult
impl BitXorAssign<SnapshotResult> for SnapshotResult
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
Toggles the set of flags.
source§impl Clone for SnapshotResult
impl Clone for SnapshotResult
source§fn clone(&self) -> SnapshotResult
fn clone(&self) -> SnapshotResult
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SnapshotResult
impl Debug for SnapshotResult
source§impl Default for SnapshotResult
impl Default for SnapshotResult
source§fn default() -> SnapshotResult
fn default() -> SnapshotResult
source§impl Extend<SnapshotResult> for SnapshotResult
impl Extend<SnapshotResult> for SnapshotResult
source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl FromIterator<SnapshotResult> for SnapshotResult
impl FromIterator<SnapshotResult> for SnapshotResult
source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
source§impl Hash for SnapshotResult
impl Hash for SnapshotResult
source§impl LowerHex for SnapshotResult
impl LowerHex for SnapshotResult
source§impl Not for SnapshotResult
impl Not for SnapshotResult
source§impl Octal for SnapshotResult
impl Octal for SnapshotResult
source§impl Ord for SnapshotResult
impl Ord for SnapshotResult
source§fn cmp(&self, other: &SnapshotResult) -> Ordering
fn cmp(&self, other: &SnapshotResult) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<SnapshotResult> for SnapshotResult
impl PartialEq<SnapshotResult> for SnapshotResult
source§fn eq(&self, other: &SnapshotResult) -> bool
fn eq(&self, other: &SnapshotResult) -> bool
source§impl PartialOrd<SnapshotResult> for SnapshotResult
impl PartialOrd<SnapshotResult> for SnapshotResult
source§fn partial_cmp(&self, other: &SnapshotResult) -> Option<Ordering>
fn partial_cmp(&self, other: &SnapshotResult) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Sub<SnapshotResult> for SnapshotResult
impl Sub<SnapshotResult> for SnapshotResult
source§impl SubAssign<SnapshotResult> for SnapshotResult
impl SubAssign<SnapshotResult> for SnapshotResult
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Disables all flags enabled in the set.
source§impl UpperHex for SnapshotResult
impl UpperHex for SnapshotResult
impl Copy for SnapshotResult
impl Eq for SnapshotResult
impl StructuralEq for SnapshotResult
impl StructuralPartialEq for SnapshotResult
Auto Trait Implementations§
impl RefUnwindSafe for SnapshotResult
impl Send for SnapshotResult
impl Sync for SnapshotResult
impl Unpin for SnapshotResult
impl UnwindSafe for SnapshotResult
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
source§fn into_sample(self) -> S
fn into_sample(self) -> S
S
a sample type from self
.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more