Skip to content

Commit

Permalink
Add zino-files and zino-channel crates
Browse files Browse the repository at this point in the history
  • Loading branch information
photino committed Dec 14, 2024
1 parent f2e7d33 commit d1fd1e0
Show file tree
Hide file tree
Showing 28 changed files with 303 additions and 139 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"zino-derive",
"zino-dioxus",
"zino-extra",
"zino-files",
"zino-http",
"zino-middleware",
"zino-model",
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ fn main() {
| Name | Description | Crates.io | Documentation |
|-----------------|-----------------------------------|--------------|---------------|
| [`zino-core`] | Core types and traits. | [![Crates.io](https://img.shields.io/crates/v/zino-core)][zino-core] | [![Documentation](https://shields.io/docsrs/zino-core)][zino-core-docs] |
| [`zino-derive`] | Derived traits. | [![Crates.io](https://img.shields.io/crates/v/zino-derive)][zino-derive] | [![Documentation](https://shields.io/docsrs/zino-derive)][zino-derive-docs] |
| [`zino-model`] | Domain models. | [![Crates.io](https://img.shields.io/crates/v/zino-model)][zino-model] | [![Documentation](https://shields.io/docsrs/zino-model)][zino-model-docs] |
| [`zino-auth`] | Authentication and authorization. | [![Crates.io](https://img.shields.io/crates/v/zino-auth)][zino-auth] | [![Documentation](https://shields.io/docsrs/zino-auth)][zino-auth-docs] |
| [`zino-http`] | Requests and responses. | [![Crates.io](https://img.shields.io/crates/v/zino-http)][zino-http] | [![Documentation](https://shields.io/docsrs/zino-http)][zino-http-docs] |
| [`zino-derive`] | Derived traits. | [![Crates.io](https://img.shields.io/crates/v/zino-derive)][zino-derive] | [![Documentation](https://shields.io/docsrs/zino-derive)][zino-derive-docs] |
| [`zino-model`] | Domain models. | [![Crates.io](https://img.shields.io/crates/v/zino-model)][zino-model] | [![Documentation](https://shields.io/docsrs/zino-model)][zino-model-docs] |
| [`zino-extra`] | Extra utilities. | [![Crates.io](https://img.shields.io/crates/v/zino-extra)][zino-extra] | [![Documentation](https://shields.io/docsrs/zino-extra)][zino-extra-docs] |
| [`zino-actix`] | Integrations with actix-web. | [![Crates.io](https://img.shields.io/crates/v/zino-actix)][zino-actix] | [![Documentation](https://shields.io/docsrs/zino-actix)][zino-actix-docs] |
| [`zino-axum`] | Integrations with axum. | [![Crates.io](https://img.shields.io/crates/v/zino-axum)][zino-axum] | [![Documentation](https://shields.io/docsrs/zino-axum)][zino-axum-docs] |
Expand All @@ -75,10 +75,10 @@ This project is licensed under the [MIT license][license].
If you have any problems or ideas, please don't hesitate to [open an issue][zino-issue].

[`zino-core`]: https://github.com/zino-rs/zino/tree/main/zino-core
[`zino-derive`]: https://github.com/zino-rs/zino/tree/main/zino-derive
[`zino-model`]: https://github.com/zino-rs/zino/tree/main/zino-model
[`zino-auth`]: https://github.com/zino-rs/zino/tree/main/zino-auth
[`zino-http`]: https://github.com/zino-rs/zino/tree/main/zino-http
[`zino-derive`]: https://github.com/zino-rs/zino/tree/main/zino-derive
[`zino-model`]: https://github.com/zino-rs/zino/tree/main/zino-model
[`zino-extra`]: https://github.com/zino-rs/zino/tree/main/zino-extra
[`zino-actix`]: https://github.com/zino-rs/zino/tree/main/zino-actix
[`zino-axum`]: https://github.com/zino-rs/zino/tree/main/zino-axum
Expand All @@ -90,14 +90,14 @@ If you have any problems or ideas, please don't hesitate to [open an issue][zino
[zino-docs]: https://docs.rs/zino
[zino-core]: https://crates.io/crates/zino-core
[zino-core-docs]: https://docs.rs/zino-core
[zino-derive]: https://crates.io/crates/zino-derive
[zino-derive-docs]: https://docs.rs/zino-derive
[zino-model]: https://crates.io/crates/zino-model
[zino-model-docs]: https://docs.rs/zino-model
[zino-auth]: https://crates.io/crates/zino-auth
[zino-auth-docs]: https://docs.rs/zino-auth
[zino-http]: https://crates.io/crates/zino-http
[zino-http-docs]: https://docs.rs/zino-http
[zino-derive]: https://crates.io/crates/zino-derive
[zino-derive-docs]: https://docs.rs/zino-derive
[zino-model]: https://crates.io/crates/zino-model
[zino-model-docs]: https://docs.rs/zino-model
[zino-extra]: https://crates.io/crates/zino-extra
[zino-extra-docs]: https://docs.rs/zino-extra
[zino-actix]: https://crates.io/crates/zino-actix
Expand Down
48 changes: 48 additions & 0 deletions zino-channel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
name = "zino-channel"
description = "Cloud events and subscriptions for zino."
version = "0.1.0"
rust-version = "1.80"
edition = "2021"
license = "MIT"
categories = ["asynchronous", "network-programming", "web-programming"]
keywords = ["http", "web", "framework"]
homepage = "https://github.com/zino-rs/zino"
repository = "https://github.com/zino-rs/zino"
documentation = "https://docs.rs/zino-channel"
readme = "README.md"

[features]
flume = [
"dep:ahash",
"dep:flume",
"dep:futures",
"dep:parking_lot",
]

[dependencies]
serde_json = "1.0.133"

[dependencies.ahash]
version = "0.8.11"
optional = true

[dependencies.flume]
version = "0.11.1"
optional = true

[dependencies.futures]
version = "0.3.31"
optional = true

[dependencies.parking_lot]
version = "0.12.3"
optional = true

[dependencies.serde]
version = "1.0.216"
features = ["derive"]

[dependencies.zino-core]
path = "../zino-core"
version = "0.29.2"
20 changes: 20 additions & 0 deletions zino-channel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[![github]](https://github.com/zino-rs/zino)
[![crates-io]](https://crates.io/crates/zino-channel)
[![docs-rs]](https://docs.rs/zino-channel)

[github]: https://img.shields.io/badge/github-8da0cb?labelColor=555555&logo=github
[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?labelColor=555555&logo=rust
[docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?labelColor=555555&logo=docs.rs

Cloud events and subscriptions for [`zino`].

## Feature flags

The following optional features are available:

| Name | Description | Default? |
|----------------------|--------------------------------------------------------|----------|
| `flume` | Enables the message channel via [`flume`]. | No |

[`zino`]: https://github.com/zino-rs/zino
[`flume`]: https://crates.io/crates/flume
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{datetime::DateTime, JsonValue, Map, SharedString};
use serde::{Deserialize, Serialize};
use zino_core::{datetime::DateTime, JsonValue, Map, SharedString};

/// Cloud event.
/// See [the spec](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{CloudEvent, Subscription};
use crate::{extension::TomlTableExt, state::State, LazyLock, Uuid};
use ahash::{HashMap, HashMapExt};
use flume::{Receiver, SendError, Sender, TrySendError};
use futures::{Sink, Stream};
use parking_lot::RwLock;
use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
use zino_core::{extension::TomlTableExt, state::State, LazyLock, Uuid};

/// A emitter is a sender of cloud events.
type Emitter = Sender<CloudEvent>;
Expand Down
17 changes: 17 additions & 0 deletions zino-channel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc = include_str!("../README.md")]
#![doc(html_favicon_url = "https://zino.cc/assets/zino-logo.png")]
#![doc(html_logo_url = "https://zino.cc/assets/zino-logo.svg")]
#![forbid(unsafe_code)]

mod cloud_event;
mod subscription;

pub use cloud_event::CloudEvent;
pub use subscription::Subscription;

#[cfg(feature = "flume")]
mod flume;

#[cfg(feature = "flume")]
pub use flume::MessageChannel;
File renamed without changes.
88 changes: 1 addition & 87 deletions zino-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,6 @@ cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]

[features]
accessor = ["opendal"]
accessor-azblob = ["accessor", "opendal/services-azblob"]
accessor-azdls = ["accessor", "opendal/services-azdls"]
accessor-cacache = ["accessor", "opendal/services-cacache"]
accessor-cos = ["accessor", "opendal/services-cos"]
accessor-dashmap = ["accessor", "opendal/services-dashmap"]
accessor-dropbox = ["accessor", "opendal/services-dropbox"]
accessor-fs = ["accessor", "opendal/services-fs"]
accessor-gcs = ["accessor", "opendal/services-gcs"]
accessor-gdrive = ["accessor", "opendal/services-gdrive"]
accessor-ghac = ["accessor", "opendal/services-ghac"]
accessor-http = ["accessor", "opendal/services-http"]
accessor-ipfs = ["accessor", "opendal/services-ipfs"]
accessor-ipmfs = ["accessor", "opendal/services-ipmfs"]
accessor-memcached = ["accessor", "opendal/services-memcached"]
accessor-memory = ["accessor", "opendal/services-memory"]
accessor-mini-moka = ["accessor", "opendal/services-mini-moka"]
accessor-moka = ["accessor", "opendal/services-moka"]
accessor-mysql = ["accessor", "opendal/services-mysql"]
accessor-obs = ["accessor", "opendal/services-obs"]
accessor-onedrive = ["accessor", "opendal/services-onedrive"]
accessor-oss = ["accessor", "opendal/services-oss"]
accessor-persy = ["accessor", "opendal/services-persy"]
accessor-postgresql = ["accessor", "opendal/services-postgresql"]
accessor-redb = ["accessor", "opendal/services-redb"]
accessor-redis = ["accessor", "opendal/services-redis"]
accessor-s3 = ["accessor", "opendal/services-s3"]
accessor-sled = ["accessor", "opendal/services-sled"]
accessor-supabase = ["accessor", "opendal/services-supabase"]
accessor-webdav = ["accessor", "opendal/services-webdav"]
accessor-webhdfs = ["accessor", "opendal/services-webhdfs"]
all-accessors = [
"accessor",
"accessor-azblob",
"accessor-azdls",
"accessor-cacache",
"accessor-cos",
"accessor-dashmap",
"accessor-dropbox",
"accessor-fs",
"accessor-gcs",
"accessor-gdrive",
"accessor-ghac",
"accessor-http",
"accessor-ipfs",
"accessor-ipmfs",
"accessor-memcached",
"accessor-memory",
"accessor-mini-moka",
"accessor-moka",
"accessor-mysql",
"accessor-obs",
"accessor-onedrive",
"accessor-oss",
"accessor-persy",
"accessor-postgresql",
"accessor-redb",
"accessor-redis",
"accessor-s3",
"accessor-sled",
"accessor-supabase",
"accessor-webdav",
"accessor-webhdfs",
]
all-chatbots = ["chatbot", "chatbot-openai"]
all-connectors = [
"connector",
Expand Down Expand Up @@ -127,17 +63,14 @@ debug = [
default = []
dotenv = ["dep:dotenvy"]
env-filter = ["tracing-subscriber/env-filter", "tracing-subscriber/smallvec"]
flume = ["dep:flume"]
full = [
"all-accessors",
"all-chatbots",
"all-connectors",
"all-locales",
"all-validators",
"cookie",
"dotenv",
"env-filter",
"flume",
"http-client",
"metrics",
"oidc",
Expand All @@ -153,11 +86,7 @@ locale-es = ["locale", "random_word/es"]
locale-de = ["locale", "random_word/de"]
locale-fr = ["locale", "random_word/fr"]
locale-zh = ["locale", "random_word/zh"]
metrics = [
"dep:metrics",
"dep:metrics-exporter-prometheus",
"opendal?/layers-metrics",
]
metrics = ["dep:metrics", "dep:metrics-exporter-prometheus"]
oidc = ["dep:rauthy-client"]
openapi = ["dep:utoipa"]
orm = ["orm-sqlx"]
Expand Down Expand Up @@ -196,21 +125,16 @@ aes-gcm-siv = "0.11.1"
ahash = "0.8.11"
apache-avro = "0.17.0"
base64 = "0.22.1"
bytes = "1.9.0"
cfg-if = "1.0"
convert_case = "0.6.0"
cron = "0.13.0"
csv = "1.3.1"
dirs = "5.0.1"
etag = "4.0.0"
faster-hex = "0.10.0"
futures = "0.3.31"
hkdf = "0.12.4"
hmac = "0.12.1"
http = "1.2.0"
md-5 = "0.10.6"
mime_guess = "2.0.5"
multer = "3.1.0"
parking_lot = "0.12.3"
percent-encoding = "2.3.1"
rand = "0.8.5"
Expand Down Expand Up @@ -255,10 +179,6 @@ optional = true
version = "0.15.7"
optional = true

[dependencies.flume]
version = "0.11.1"
optional = true

[dependencies.metrics]
version = "0.24.1"
optional = true
Expand All @@ -274,12 +194,6 @@ version = "2.5.0"
optional = true
features = ["loader"]

[dependencies.opendal]
version = "0.50.2"
optional = true
default-features = false
features = ["layers-tracing"]

[dependencies.phonenumber]
version = "0.3.6"
optional = true
Expand Down
4 changes: 0 additions & 4 deletions zino-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ The following optional features are available:

| Name | Description | Default? |
|----------------------|--------------------------------------------------------|----------|
| `accessor` | Enables the data access layer built with [`opendal`]. | No |
| `chatbot` | Enables the chatbot services. | No |
| `connector` | Enables the data source connectors. | No |
| `cookie` | Enables the support for cookies. | No |
| `crypto-sm` | Enables China's Standards of Encryption Algorithms. | No |
| `debug` | Enables the features for ease of debugging. | No |
| `dotenv` | Enables the configuration loader for a `.env` file. | No |
| `env-filter` | Enables the `env-filter` for [`tracing-subscriber`]. | No |
| `flume` | Enables the message channel via [`flume`]. | No |
| `http-client` | Enables the HTTP client via [`reqwest`]. | No |
| `locale` | Enables the support for locale related utilities. | No |
| `metrics` | Enables the [`metrics`] exporter. | No |
Expand All @@ -40,9 +38,7 @@ The following optional features are available:
| `view` | Enables the HTML template rendering. | No |

[`zino`]: https://github.com/zino-rs/zino
[`opendal`]: https://crates.io/crates/opendal
[`tracing-subscriber`]: https://crates.io/crates/tracing-subscriber
[`flume`]: https://crates.io/crates/flume
[`reqwest`]: https://crates.io/crates/reqwest
[`metrics`]: https://crates.io/crates/metrics
[`async-std`]: https://crates.io/crates/async-std
Expand Down
13 changes: 0 additions & 13 deletions zino-core/src/channel/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion zino-core/src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cfg_if::cfg_if! {

mod sha1;

pub(crate) use sha1::checksum;
pub use sha1::checksum;
2 changes: 1 addition & 1 deletion zino-core/src/crypto/sha1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sha1::{Digest, Sha1};

/// SHA1 digest
pub(crate) fn checksum(data: &[u8]) -> [u8; 20] {
pub fn checksum(data: &[u8]) -> [u8; 20] {
let mut hasher = Sha1::new();
hasher.update(data);
hasher.finalize().into()
Expand Down
4 changes: 0 additions & 4 deletions zino-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ mod mock;
#[cfg(feature = "openapi")]
mod openapi;

#[cfg(feature = "accessor")]
pub mod accessor;
#[cfg(feature = "chatbot")]
pub mod chatbot;
#[cfg(feature = "connector")]
Expand All @@ -22,13 +20,11 @@ pub mod orm;
pub mod view;

pub mod application;
pub mod channel;
pub mod crypto;
pub mod datetime;
pub mod encoding;
pub mod error;
pub mod extension;
pub mod file;
pub mod model;
pub mod schedule;
pub mod state;
Expand Down
4 changes: 4 additions & 0 deletions zino-dioxus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ features = [
path = "../zino-core"
version = "0.29.2"
features = ["runtime-tokio"]

[dependencies.zino-files]
path = "../zino-files"
version = "0.1.0"
Loading

0 comments on commit d1fd1e0

Please sign in to comment.