Can't build serde Serialize implementation

Hi!
I try to build this code

#[derive(Serialize)]
struct Query {
    query: Bool
}

#[derive(Serialize)]
struct Bool {
    bool: Must
}

#[derive(Serialize)]
struct Must {
    must: Term
}

struct Term {
    name: String,
    value: TermValue
}

#[derive(Serialize)]
struct TermValue {
    value: String
}

impl Serialize for Term {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
            where S: Serializer {
        let mut term = serializer.serialize_struct("Term", 1)?;
        term.serialize_field(&self.name, &self.value.serialize(serializer))?;
        term.end()
    }
}

and get errors

error[E0277]: the trait bound `<S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Ok: requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` is not satisfied
  --> src/requester/mod.rs:44:14
   |
44 |         term.serialize_field(&self.name, &self.value.serialize(serializer))?;
   |              ^^^^^^^^^^^^^^^ the trait `requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` is not implemented for `<S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Ok`
   |
   = help: consider adding a `where <S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Ok: requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` bound
   = note: required because of the requirements on the impl of `requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` for `std::result::Result<<S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Ok, <S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Error>`

error[E0277]: the trait bound `<S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Error: requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` is not satisfied
  --> src/requester/mod.rs:44:14
   |
44 |         term.serialize_field(&self.name, &self.value.serialize(serializer))?;
   |              ^^^^^^^^^^^^^^^ the trait `requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` is not implemented for `<S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Error`
   |
   = help: consider adding a `where <S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Error: requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` bound
   = note: required because of the requirements on the impl of `requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serialize` for `std::result::Result<<S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Ok, <S as requester::_IMPL_SERIALIZE_FOR_Query::_serde::Serializer>::Error>`

I don't understand why term type is Serializer::Ok instead of SerializeStruct? Why compiler check implementation Serialize for both Ok and Error.
And why error appear on type requester::IMPL_SERIALIZE_FOR_Query::_serde::Serializer in spite of trait be implemented for Term??!!

Try adding serde crate to the project. serde_derive requires serde.

Because you are passing &self.value.serialize(serializer) into serialize_field(). And the return value of that function is Result<S::Ok, S::Error>.

This doesn't really make sense; you probably want to just pass &self.value directly instead, since that value is what you want to serialize, not the (arbitrary, generic) return value of whatever the serializer spits out.

Yes! Thank you!