merge stable version #2
|
@ -5,21 +5,6 @@ use crate::{
|
|||
model::models::*,
|
||||
};
|
||||
|
||||
/// **Синдромы**
|
||||
///
|
||||
/// ошибочная позиция 1 false true true.
|
||||
///
|
||||
/// ошибочная позиция 2 false false true.
|
||||
///
|
||||
/// ошибочная позиция 3 true false true.
|
||||
///
|
||||
/// ошибочная позиция 4 false true false.
|
||||
///
|
||||
/// ошибочная позиция 5 true true false.
|
||||
///
|
||||
/// ошибочная позиция 6 true false false.
|
||||
///
|
||||
/// ошибочная позиция 7 false false false.
|
||||
|
||||
pub fn hamming(raw_input: String, mode: HammingMode) -> Result<String, String> {
|
||||
let length_of_code: usize = mode.clone() as usize;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
pub trait Product<B, T> {
|
||||
fn builder() -> B;
|
||||
|
||||
fn get(self) -> T;
|
||||
fn get(&self) -> &T;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub trait Builder<T, I, P> {
|
||||
fn build(&self, build_arg: P) -> T;
|
||||
|
||||
|
|
|
@ -2,14 +2,19 @@ pub mod builder_traits;
|
|||
pub mod models;
|
||||
|
||||
use crate::gtk::glib;
|
||||
|
||||
use glib::Object;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct ResultValue(ObjectSubclass<models::ResultValue>);
|
||||
pub struct Frequency(ObjectSubclass<models::Frequency>);
|
||||
}
|
||||
|
||||
impl ResultValue {
|
||||
pub fn new(val: f64) -> Self {
|
||||
Object::builder().property("value", val).build()
|
||||
impl Frequency {
|
||||
pub fn new(frequency: f64) -> Self {
|
||||
Object::builder().property("frequency", frequency).build()
|
||||
}
|
||||
|
||||
pub fn default() -> Self {
|
||||
Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ use std::cell::Cell;
|
|||
|
||||
use crate::gtk;
|
||||
|
||||
use glib::Properties;
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{
|
||||
glib::{self, Properties},
|
||||
prelude::*,
|
||||
subclass::prelude::*,
|
||||
};
|
||||
|
||||
#[repr(usize)]
|
||||
#[derive(Clone)]
|
||||
|
@ -14,33 +15,29 @@ pub enum HammingMode {
|
|||
Decrypt = 7,
|
||||
}
|
||||
|
||||
pub struct EventHandler<F, C> {
|
||||
pub(crate) component: C,
|
||||
pub(crate) callback: F,
|
||||
}
|
||||
|
||||
#[derive(Default, Copy, Clone)]
|
||||
pub struct SignalReduce(pub f64, pub f64, pub f64, pub f64, pub f64, pub f64);
|
||||
|
||||
impl SignalReduce {
|
||||
pub fn new() -> Self {
|
||||
Self(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
#[derive(Default, Copy, Clone, Debug)]
|
||||
pub struct SignalReduce {
|
||||
pub length: f64,
|
||||
pub wire_resistance: f64,
|
||||
pub wire_capacity: f64,
|
||||
pub source_voltage: f64,
|
||||
pub source_resistance: f64,
|
||||
pub frequency: f64,
|
||||
}
|
||||
|
||||
#[derive(Properties, Default)]
|
||||
#[properties(wrapper_type = super::ResultValue)]
|
||||
pub struct ResultValue {
|
||||
#[properties(wrapper_type = super::Frequency)]
|
||||
pub struct Frequency {
|
||||
#[property(get, set)]
|
||||
value: Cell<f64>,
|
||||
}
|
||||
|
||||
// The central trait for subclassing a GObject
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for ResultValue {
|
||||
const NAME: &'static str = "MyGtkAppCustomButton";
|
||||
type Type = super::ResultValue;
|
||||
frequency: Cell<f64>,
|
||||
}
|
||||
|
||||
#[glib::derived_properties]
|
||||
impl ObjectImpl for ResultValue {}
|
||||
impl ObjectImpl for Frequency {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Frequency {
|
||||
const NAME: &'static str = "FrequencyValue";
|
||||
type Type = super::Frequency;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue