Starting fsk demod
This commit is contained in:
@ -22,6 +22,14 @@ pub struct Tag
|
||||
|
||||
impl Tag
|
||||
{
|
||||
pub fn new() -> Self
|
||||
{
|
||||
Self {
|
||||
position: 0,
|
||||
data: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn merge_tag_opts<const N: usize>(tag_opts: [Option<Tag>; N]) -> Option<Tag>
|
||||
{
|
||||
let mut out_tag = None;
|
||||
@ -31,6 +39,27 @@ impl Tag
|
||||
}
|
||||
out_tag
|
||||
}
|
||||
|
||||
pub fn tag<T: 'static + Send + Sync>(&self, key: impl AsRef<str>, value: T)
|
||||
{
|
||||
self.data
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(key.as_ref().to_owned(), Arc::new(value));
|
||||
}
|
||||
|
||||
pub fn retrieve(&self, key: impl AsRef<str>) -> Option<Arc<dyn Any + Send + Sync>>
|
||||
{
|
||||
self.data.lock().unwrap().get(key.as_ref()).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Tag
|
||||
{
|
||||
fn default() -> Self
|
||||
{
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TagValue: Clone {}
|
||||
@ -93,6 +122,10 @@ impl<T> Tagged<T>
|
||||
{
|
||||
pub fn new(inner: T, tag: Option<Tag>) -> Self
|
||||
{
|
||||
if tag.is_none()
|
||||
{
|
||||
//println!("data has no tag");
|
||||
}
|
||||
Self(inner, tag)
|
||||
}
|
||||
|
||||
@ -156,11 +189,11 @@ impl<T> From<(T, Option<Tag>)> for Tagged<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Into<(T, Option<Tag>)> for Tagged<T>
|
||||
impl<T> From<Tagged<T>> for (T, Option<Tag>)
|
||||
{
|
||||
fn into(self) -> (T, Option<Tag>)
|
||||
fn from(val: Tagged<T>) -> Self
|
||||
{
|
||||
(self.0, self.1)
|
||||
(val.0, val.1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user