Skip to content

Commit

Permalink
Fix: add some license for every files
Browse files Browse the repository at this point in the history
- extract UrlParam to single file
- fix github ci error
  • Loading branch information
onewe committed Mar 14, 2024
1 parent ca82644 commit 49426e3
Show file tree
Hide file tree
Showing 47 changed files with 963 additions and 731 deletions.
1 change: 1 addition & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
image: nacos/nacos-server:v2.3.1
ports:
- 8848:8848
- 9848:9848
env:
MODE: standalone
steps:
Expand Down
69 changes: 69 additions & 0 deletions common/base/src/extension_param.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
use crate::{url::UrlParam, StdError};
use std::{borrow::Cow, convert::Infallible, str::FromStr};

pub struct ExtensionName(String);

impl ExtensionName {
pub fn new(name: String) -> Self {
ExtensionName(name)
}
}

impl UrlParam for ExtensionName {
type TargetType = String;

fn name() -> &'static str {
"extension-name"
}

fn value(&self) -> Self::TargetType {
self.0.clone()
}

fn as_str(&self) -> Cow<str> {
self.0.as_str().into()
}
}

impl FromStr for ExtensionName {
type Err = StdError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(ExtensionName::new(s.to_string()))
}
}

pub enum ExtensionType {
Registry,
}

impl UrlParam for ExtensionType {
type TargetType = String;

fn name() -> &'static str {
"extension-type"
}

fn value(&self) -> Self::TargetType {
match self {
ExtensionType::Registry => "registry".to_owned(),
}
}

fn as_str(&self) -> Cow<str> {
match self {
ExtensionType::Registry => Cow::Borrowed("registry"),
}
}
}

impl FromStr for ExtensionType {
type Err = Infallible;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"registry" => Ok(ExtensionType::Registry),
_ => panic!("the extension type enum is not in range"),
}
}
}
4 changes: 4 additions & 0 deletions common/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
allow(dead_code, unused_imports, unused_variables, unused_mut)
)]
pub mod constants;
pub mod extension_param;
pub mod node;
pub mod registry_param;
pub mod url;

pub use node::Node;
pub use url::Url;

pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
Loading

0 comments on commit 49426e3

Please sign in to comment.