Skip to content

Generic wrappers #199

Description

@vikigenius

Should I always wrap my FDs in a generic wrapper even if I implement EventSource and just have a single source?

pub struct IPCSource {
    socket_source: calloop::generic::Generic<calloop::generic::FdWrapper<UnixListener>>,
}

impl calloop::EventSource for IPCSource {
...
}

vs

pub struct IPCSource {
    socket: UnixListener,
}

impl calloop::EventSource for IPCSource {
...
}

And if I do wrap it in a Generic:

How should I process events

    fn process_events<F>(
        &mut self,
        readiness: calloop::Readiness,
        token: calloop::Token,
        callback: F,
    ) -> Result<calloop::PostAction, Self::Error>
    where
        F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,
    {
        self.socket_source
            .process_events(readiness, token, |evt, _| {
                if readiness.readable {
                    // TODO
                }
            });
        Ok(calloop::PostAction::Continue)
    }

vs

    fn process_events<F>(
        &mut self,
        readiness: calloop::Readiness,
        token: calloop::Token,
        callback: F,
    ) -> Result<calloop::PostAction, Self::Error>
    where
        F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,
    {
        
        if readiness.readable {
                    // TODO
        }
        Ok(calloop::PostAction::Continue)
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions