fix: compilation with --no-default-features (#593)
This commit is contained in:
parent
df6c3f0665
commit
53b64a9f87
4 changed files with 10 additions and 9 deletions
|
|
@ -77,7 +77,7 @@ chrono = { version = "0.4.38", default-features = false, features = [
|
||||||
[features]
|
[features]
|
||||||
default = ["base64", "macros", "server"]
|
default = ["base64", "macros", "server"]
|
||||||
client = ["dep:tokio-stream"]
|
client = ["dep:tokio-stream"]
|
||||||
server = ["transport-async-rw", "dep:schemars"]
|
server = ["transport-async-rw", "dep:schemars", "dep:pastey"]
|
||||||
macros = ["dep:rmcp-macros", "dep:pastey"]
|
macros = ["dep:rmcp-macros", "dep:pastey"]
|
||||||
elicitation = []
|
elicitation = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use std::{borrow::Cow, fmt::Display};
|
use std::{borrow::Cow, fmt::Display};
|
||||||
|
|
||||||
use crate::ServiceError;
|
|
||||||
pub use crate::model::ErrorData;
|
pub use crate::model::ErrorData;
|
||||||
#[deprecated(
|
#[deprecated(
|
||||||
note = "Use `rmcp::ErrorData` instead, `rmcp::ErrorData` could become `RmcpError` in the future."
|
note = "Use `rmcp::ErrorData` instead, `rmcp::ErrorData` could become `RmcpError` in the future."
|
||||||
|
|
@ -22,8 +21,9 @@ impl std::error::Error for ErrorData {}
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum RmcpError {
|
pub enum RmcpError {
|
||||||
|
#[cfg(any(feature = "client", feature = "server"))]
|
||||||
#[error("Service error: {0}")]
|
#[error("Service error: {0}")]
|
||||||
Service(#[from] ServiceError),
|
Service(#[from] crate::ServiceError),
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
#[error("Client initialization error: {0}")]
|
#[error("Client initialization error: {0}")]
|
||||||
ClientInitialize(#[from] crate::service::ClientInitializeError),
|
ClientInitialize(#[from] crate::service::ClientInitializeError),
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ pub use pastey::paste;
|
||||||
#[cfg(all(feature = "macros", feature = "server"))]
|
#[cfg(all(feature = "macros", feature = "server"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "macros", feature = "server"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "macros", feature = "server"))))]
|
||||||
pub use rmcp_macros::*;
|
pub use rmcp_macros::*;
|
||||||
#[cfg(all(feature = "macros", feature = "server"))]
|
#[cfg(any(feature = "macros", feature = "server"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "macros", feature = "server"))))]
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "macros", feature = "server"))))]
|
||||||
pub use schemars;
|
pub use schemars;
|
||||||
#[cfg(feature = "macros")]
|
#[cfg(feature = "macros")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
use base64::engine::{Engine, general_purpose::STANDARD as BASE64_STANDARD};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
AnnotateAble, Annotations, Icon, Meta, RawEmbeddedResource, RawImageContent,
|
AnnotateAble, Annotations, Icon, Meta, RawEmbeddedResource,
|
||||||
content::{EmbeddedResource, ImageContent},
|
content::{EmbeddedResource, ImageContent},
|
||||||
resource::ResourceContents,
|
resource::ResourceContents,
|
||||||
};
|
};
|
||||||
|
|
@ -138,11 +137,13 @@ impl PromptMessage {
|
||||||
meta: Option<crate::model::Meta>,
|
meta: Option<crate::model::Meta>,
|
||||||
annotations: Option<Annotations>,
|
annotations: Option<Annotations>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
use base64::{Engine, prelude::BASE64_STANDARD};
|
||||||
|
|
||||||
let base64 = BASE64_STANDARD.encode(data);
|
let base64 = BASE64_STANDARD.encode(data);
|
||||||
Self {
|
Self {
|
||||||
role,
|
role,
|
||||||
content: PromptMessageContent::Image {
|
content: PromptMessageContent::Image {
|
||||||
image: RawImageContent {
|
image: crate::model::RawImageContent {
|
||||||
data: base64,
|
data: base64,
|
||||||
mime_type: mime_type.into(),
|
mime_type: mime_type.into(),
|
||||||
meta,
|
meta,
|
||||||
|
|
@ -215,7 +216,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_prompt_message_image_serialization() {
|
fn test_prompt_message_image_serialization() {
|
||||||
let image_content = RawImageContent {
|
let image_content = crate::model::RawImageContent {
|
||||||
data: "base64data".to_string(),
|
data: "base64data".to_string(),
|
||||||
mime_type: "image/png".to_string(),
|
mime_type: "image/png".to_string(),
|
||||||
meta: None,
|
meta: None,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue