pub struct DatasourceId(/* private fields */);
Expand description
A unique identifier for a datasource in the pipeline.
Datasource IDs are used to track the source of data updates and enable filtering of updates based on their origin. This is particularly useful when you have multiple datasources and want to process updates selectively.
§Examples
Creating a datasource with a unique ID:
use carbon_core::datasource::DatasourceId;
let id = DatasourceId::new_unique();
println!("Generated ID: {:?}", id);
Creating a datasource with a named ID:
use carbon_core::datasource::DatasourceId;
let id = DatasourceId::new_named("mainnet-rpc");
println!("Named ID: {:?}", id);
Using with filters:
use carbon_core::{datasource::DatasourceId, filter::DatasourceFilter};
let datasource_id = DatasourceId::new_named("testnet");
let filter = DatasourceFilter::new(datasource_id);
Implementations§
Source§impl DatasourceId
impl DatasourceId
Sourcepub fn new_unique() -> Self
pub fn new_unique() -> Self
Creates a new datasource ID with a randomly generated unique identifier.
This method uses a cryptographically secure random number generator to create a unique ID. The ID is converted to a string representation for easy debugging and logging.
§Returns
A new DatasourceId
with a unique random identifier.
§Examples
use carbon_core::datasource::DatasourceId;
let id1 = DatasourceId::new_unique();
let id2 = DatasourceId::new_unique();
assert_ne!(id1, id2); // IDs should be different
Sourcepub fn new_named(name: &str) -> Self
pub fn new_named(name: &str) -> Self
Creates a new datasource ID with a specific name.
This method is useful when you want to assign a meaningful name to a datasource for easier identification and debugging.
§Arguments
name
- A string slice containing the name for the datasource ID
§Returns
A new DatasourceId
with the specified name.
§Examples
use carbon_core::datasource::DatasourceId;
let mainnet_id = DatasourceId::new_named("mainnet-rpc");
let testnet_id = DatasourceId::new_named("testnet-rpc");
assert_ne!(mainnet_id, testnet_id);
Trait Implementations§
Source§impl Clone for DatasourceId
impl Clone for DatasourceId
Source§fn clone(&self) -> DatasourceId
fn clone(&self) -> DatasourceId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for DatasourceId
impl Debug for DatasourceId
Source§impl Hash for DatasourceId
impl Hash for DatasourceId
Source§impl PartialEq for DatasourceId
impl PartialEq for DatasourceId
impl Eq for DatasourceId
impl StructuralPartialEq for DatasourceId
Auto Trait Implementations§
impl Freeze for DatasourceId
impl RefUnwindSafe for DatasourceId
impl Send for DatasourceId
impl Sync for DatasourceId
impl Unpin for DatasourceId
impl UnwindSafe for DatasourceId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more