Skip to content

Commit

Permalink
Now injecting /v2/context into the store API
Browse files Browse the repository at this point in the history
  • Loading branch information
Lut99 committed Dec 2, 2024
1 parent 6379dae commit 35ee244
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 77 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 106 additions & 16 deletions brane-cfg/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created:
// 28 Feb 2023, 10:01:27
// Last edited:
// 14 Nov 2024, 15:11:07
// 02 Dec 2024, 14:55:34
// Auto updated?
// Yes
//
Expand Down Expand Up @@ -168,21 +168,39 @@ impl NodeSpecificConfig {
/// # Returns
/// A reference to the internal CentralConfig struct if we were a `NodeSpecificConfig::Central`. Will return `None` otherwise.
#[inline]
pub fn try_central(&self) -> Option<&CentralConfig> { if let Self::Central(config) = self { Some(config) } else { None } }
pub fn try_central(&self) -> Option<&CentralConfig> {
if let Self::Central(config) = self {
Some(config)
} else {
None
}
}

/// Provides mutable access to the central-node specific configuration.
///
/// # Returns
/// A mutable reference to the internal CentralConfig struct if we were a `NodeSpecificConfig::Central`. Will return `None` otherwise.
#[inline]
pub fn try_central_mut(&mut self) -> Option<&mut CentralConfig> { if let Self::Central(config) = self { Some(config) } else { None } }
pub fn try_central_mut(&mut self) -> Option<&mut CentralConfig> {
if let Self::Central(config) = self {
Some(config)
} else {
None
}
}

/// Returns the internal central-node specific configuration.
///
/// # Returns
/// The internal CentralConfig struct if we were a `NodeSpecificConfig::Central`. Will return `None` otherwise.
#[inline]
pub fn try_into_central(self) -> Option<CentralConfig> { if let Self::Central(config) = self { Some(config) } else { None } }
pub fn try_into_central(self) -> Option<CentralConfig> {
if let Self::Central(config) = self {
Some(config)
} else {
None
}
}

/// Returns if this NodeSpecificConfig is a `NodeSpecificConfig::Worker`.
///
Expand Down Expand Up @@ -244,21 +262,39 @@ impl NodeSpecificConfig {
/// # Returns
/// A reference to the internal WorkerConfig struct if we were a `NodeSpecificConfig::Worker`. Will return `None` otherwise.
#[inline]
pub fn try_worker(&self) -> Option<&WorkerConfig> { if let Self::Worker(config) = self { Some(config) } else { None } }
pub fn try_worker(&self) -> Option<&WorkerConfig> {
if let Self::Worker(config) = self {
Some(config)
} else {
None
}
}

/// Provides mutable access to the worker-node specific configuration.
///
/// # Returns
/// A mutable reference to the internal WorkerConfig struct if we were a `NodeSpecificConfig::Worker`. Will return `None` otherwise.
#[inline]
pub fn try_worker_mut(&mut self) -> Option<&mut WorkerConfig> { if let Self::Worker(config) = self { Some(config) } else { None } }
pub fn try_worker_mut(&mut self) -> Option<&mut WorkerConfig> {
if let Self::Worker(config) = self {
Some(config)
} else {
None
}
}

/// Returns the internal worker-node specific configuration.
///
/// # Returns
/// The internal WorkerConfig struct if we were a `NodeSpecificConfig::Worker`. Will return `None` otherwise.
#[inline]
pub fn try_into_worker(self) -> Option<WorkerConfig> { if let Self::Worker(config) = self { Some(config) } else { None } }
pub fn try_into_worker(self) -> Option<WorkerConfig> {
if let Self::Worker(config) = self {
Some(config)
} else {
None
}
}

/// Returns if this NodeSpecificConfig is a `NodeSpecificConfig::Proxy`.
///
Expand Down Expand Up @@ -320,21 +356,39 @@ impl NodeSpecificConfig {
/// # Returns
/// A reference to the internal ProxyConfig struct if we were a `NodeSpecificConfig::Proxy`. Will return `None` otherwise.
#[inline]
pub fn try_proxy(&self) -> Option<&ProxyConfig> { if let Self::Proxy(config) = self { Some(config) } else { None } }
pub fn try_proxy(&self) -> Option<&ProxyConfig> {
if let Self::Proxy(config) = self {
Some(config)
} else {
None
}
}

/// Provides mutable access to the proxy-node specific configuration.
///
/// # Returns
/// A mutable reference to the internal ProxyConfig struct if we were a `NodeSpecificConfig::Proxy`. Will return `None` otherwise.
#[inline]
pub fn try_proxy_mut(&mut self) -> Option<&mut ProxyConfig> { if let Self::Proxy(config) = self { Some(config) } else { None } }
pub fn try_proxy_mut(&mut self) -> Option<&mut ProxyConfig> {
if let Self::Proxy(config) = self {
Some(config)
} else {
None
}
}

/// Returns the internal proxy-node specific configuration.
///
/// # Returns
/// The internal ProxyConfig struct if we were a `NodeSpecificConfig::Proxy`. Will return `None` otherwise.
#[inline]
pub fn try_into_proxy(self) -> Option<ProxyConfig> { if let Self::Proxy(config) = self { Some(config) } else { None } }
pub fn try_into_proxy(self) -> Option<ProxyConfig> {
if let Self::Proxy(config) = self {
Some(config)
} else {
None
}
}
}


Expand Down Expand Up @@ -562,21 +616,39 @@ impl PrivateOrExternalService {
/// # Returns
/// A reference to the internal `PrivateService` object if this is a `PrivateOrExternalService::Private`, or else `None`.
#[inline]
pub fn try_private(&self) -> Option<&PrivateService> { if let Self::Private(svc) = self { Some(svc) } else { None } }
pub fn try_private(&self) -> Option<&PrivateService> {
if let Self::Private(svc) = self {
Some(svc)
} else {
None
}
}

/// Provides mutable access to the internal `PrivateService` object, assuming this is one.
///
/// # Returns
/// A mutable reference to the internal `PrivateService` object if this is a `PrivateOrExternalService::Private`, or else `None`.
#[inline]
pub fn try_private_mut(&mut self) -> Option<&mut PrivateService> { if let Self::Private(svc) = self { Some(svc) } else { None } }
pub fn try_private_mut(&mut self) -> Option<&mut PrivateService> {
if let Self::Private(svc) = self {
Some(svc)
} else {
None
}
}

/// Returns the internal `PrivateService` object, assuming this is one.
///
/// # Returns
/// The internal `PrivateService` object if this is a `PrivateOrExternalService::Private`, or else `None`. This consumes `self`.
#[inline]
pub fn try_into_private(self) -> Option<PrivateService> { if let Self::Private(svc) = self { Some(svc) } else { None } }
pub fn try_into_private(self) -> Option<PrivateService> {
if let Self::Private(svc) = self {
Some(svc)
} else {
None
}
}

/// Returns whether this is an external service or not.
///
Expand Down Expand Up @@ -638,21 +710,39 @@ impl PrivateOrExternalService {
/// # Returns
/// A reference to the internal `ExternalService` object if this is a `PrivateOrExternalService::External`, or else `None`.
#[inline]
pub fn try_external(&self) -> Option<&ExternalService> { if let Self::External(svc) = self { Some(svc) } else { None } }
pub fn try_external(&self) -> Option<&ExternalService> {
if let Self::External(svc) = self {
Some(svc)
} else {
None
}
}

/// Provides mutable access to the internal `ExternalService` object, assuming this is one.
///
/// # Returns
/// A mutable reference to the internal `ExternalService` object if this is a `PrivateOrExternalService::External`, or else `None`.
#[inline]
pub fn try_external_mut(&mut self) -> Option<&mut ExternalService> { if let Self::External(svc) = self { Some(svc) } else { None } }
pub fn try_external_mut(&mut self) -> Option<&mut ExternalService> {
if let Self::External(svc) = self {
Some(svc)
} else {
None
}
}

/// Returns the internal `ExternalService` object, assuming this is one.
///
/// # Returns
/// The internal `ExternalService` object if this is a `PrivateOrExternalService::External`, or else `None`. This consumes `self`.
#[inline]
pub fn try_into_external(self) -> Option<ExternalService> { if let Self::External(svc) = self { Some(svc) } else { None } }
pub fn try_into_external(self) -> Option<ExternalService> {
if let Self::External(svc) = self {
Some(svc)
} else {
None
}
}

/// Provides access to the internal (private) address that services can connect to.
///
Expand Down
Loading

0 comments on commit 35ee244

Please sign in to comment.